I am a web developer but i don't use java script very often, but i have created a form validation from a group of different tutorial, but have run in to a brick wall trying to create a function to compare the email addresses and validate that they are the same because of the combination of different tutorial i have used.
here is the code the function is called "emailval" if anyone with a better knowledge of javascript than me could give me a head up on what missing i would be most grateful.
Expand|Select|Wrap|Line Numbers
- function emailvalidation(entered, alertbox)
- {
- with (entered)
- {
- apos=value.indexOf("@");
- dotpos=value.lastIndexOf(".");
- lastpos=value.length-1;
- if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2)
- {if (alertbox) {alert(alertbox);} return false;}
- else {return true;}
- }
- }
- function emptyvalidation(entered, alertbox)
- {
- with (entered)
- {
- if (value==null || value=="")
- {if (alertbox!="") {alert(alertbox);} return false;}
- else {return true;}
- }
- }
- function emailval(thisform)
- {
- if (entered.value != second.value)
- {if (alertbox) {alert(alertbox);} return false;}
- else {return true;}
- }
- function formvalidation(thisform)
- {
- with (thisform)
- {
- if (emailval(email,emailtwo,"The two e-mail addresses do not match")==false) {emailtwo.focus(); return false; email.focus(); return false;};
- if (emailvalidation(email,"Your E-mail Address Is Not Valid")==false) {email.focus(); return false;};
- if (emptyvalidation(name,"Please Enter Your Name")==false) {name.focus(); return false;};
- if (emptyvalidation(message,"Please Enter Your Equiry")==false) {message.focus(); return false;};
- if (emailvalidation(emailtwo,"Your E-mail Address Is Not Valid")==false) {emailtwo.focus(); return false;};
- }
- }