|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
validating a form
I want to make sure that people are entering valid emails ( atleast with @whatever.com). And i want it to make sure they retyped their email correctly. How do i do that with javascript?
Here is the form im using. <form name="form2" method="post" action="regcomplete.php"> <p>Name:<input type="text" name="name"> <br> Email:<input type="text" name="email"> <br> Retype your Email:<input type="text" name="remail"> <br> Create a password:<input type="password" name="password"> <br> <input type="submit" name="Submit" value="Sign me up!"> </p></form> Thanks alot for whatever help anyone can provide. |
|
#2
|
|||
|
|||
|
I always use the following:
PHP Code:
So with your form, you would use: PHP Code:
__________________
Sir, a desire of knowledge is the natural feeling of mankind; and every human being, whose mind is not debauched, will be willing to give all that he has to get knowledge. |
|
#3
|
|||
|
|||
|
James, I'd have thought you'd know better than responding to a 4 year old post :p
__________________
~~==~~ Whoever said nothing is impossible never tried pushing a revolving door ~~==~~ |
|
#4
|
|||
|
|||
|
I know it was 4 years old. I was just getting VERY bored at work and needed to look busy so I looked for all posts with 0 replies, no matter how old. haha- who knows, maybe it will help someone if they stumble up on it in the future. haha
|
|
#5
|
|||
|
|||
|
you could also use javascript: /regex/.test(email) to validate the email.
Code:
<script type="text/javascript">
function validateEmail(email){
return /^[a-z][\w.]*@[a-z\-]+\.[a-z]{2,4}(\.[a-z]{2,4})?$/i.test(email);
}
alert(validateEmail("test@example.com"));
</script>
But I guess you would either have to understand regular expressions (or use something like regexlib.com) to expand it further than just the email. |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Client Side Things > validating a form |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|