Eggzorcist Posted August 25, 2009 Share Posted August 25, 2009 I'm wondering wether it's possible that if there is an error as in if $error isset, it will stay on this page displaying the error otherwise, it will go to the destined action='register.php' is this possible? if so, how would i be doing this? Thanks a bunch! Quote Link to comment Share on other sites More sharing options...
merck_delmoro Posted August 25, 2009 Share Posted August 25, 2009 on your place onSubmit("return action();") on your <form> and make a function named action() or any thing you want to name it dn make a if else condition for your validation if validation creates an error return false; and if no errors return true; Quote Link to comment Share on other sites More sharing options...
Eggzorcist Posted August 26, 2009 Author Share Posted August 26, 2009 so on the register button, the onclick? I'm not sure if I understand this technique... Quote Link to comment Share on other sites More sharing options...
Eggzorcist Posted August 26, 2009 Author Share Posted August 26, 2009 So you mean if I create a onSubmit, the onSubmit function will pass before the action? meaning if Onsubmit = false it wont submit? and if its true, it full go to the action? Quote Link to comment Share on other sites More sharing options...
merck_delmoro Posted August 26, 2009 Share Posted August 26, 2009 yup Quote Link to comment Share on other sites More sharing options...
merck_delmoro Posted August 26, 2009 Share Posted August 26, 2009 place onSubmit("return action();") on your <form> and make a function named action() or any thing you want to name it dn make a if else condition for your validation if validation creates an error return false; and if no errors return true; Quote Link to comment Share on other sites More sharing options...
Eggzorcist Posted August 26, 2009 Author Share Posted August 26, 2009 Though it seems like the function has to be in javascript, it only works when it is. I tried with a php function but nothing worked. Quote Link to comment Share on other sites More sharing options...
merck_delmoro Posted August 26, 2009 Share Posted August 26, 2009 Sorry I forgot to tell you that ^^ yup the function was a JavaScript function Quote Link to comment Share on other sites More sharing options...
Eggzorcist Posted August 26, 2009 Author Share Posted August 26, 2009 Well, is there a way to create a regex style validation? So basically if I already have if (!preg_match("/\A[^0-9][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[@][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[.][a-zA-Z]{2,4}$/", $email)){ $Error .= "Email Address Must Be In format: [username]@[domain].[extension] <br />"; } is there a javascript way of doing this? My javascript is pretty bad Quote Link to comment Share on other sites More sharing options...
redarrow Posted August 26, 2009 Share Posted August 26, 2009 what are you try to validate mate, what email what? Quote Link to comment Share on other sites More sharing options...
Eggzorcist Posted August 26, 2009 Author Share Posted August 26, 2009 I'm trying to validate, firstly, a name more than 3 letters. and an email. Quote Link to comment Share on other sites More sharing options...
redarrow Posted August 26, 2009 Share Posted August 26, 2009 do u understand this mate look <?php $name="redarrow"; if(preg_match("/^[a-z]{3}$/",$name)){ echo "correct name is 3 letters long"; exit; }else{ echo "no the name was more then 3 letters long"; exit; } ?> Quote Link to comment Share on other sites More sharing options...
Eggzorcist Posted August 26, 2009 Author Share Posted August 26, 2009 Yes, I do. However, this needs to be in javascript to be able to use the onSubmit html function, because I'm trying to use the validation before the action which leads off to another file. Is there a way to implement the php regex prior the action(register.php) file? Thanks Quote Link to comment Share on other sites More sharing options...
merck_delmoro Posted August 26, 2009 Share Posted August 26, 2009 read this article http://javascript.internet.com/forms/email-validation---basic.html Quote Link to comment Share on other sites More sharing options...
mvpetrovich Posted August 26, 2009 Share Posted August 26, 2009 I think you were asking for something like this. Submit the form to the same page then: <?php if (isset($error) { echo "Error Found: $error"; } else { header('Location: register.php'); } // ... redo form ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.