I am missing something here does anyone know where i am going wrong? This is the javascript. Its linked in the head of the doc. function vailidate_form (){ vaild = true; var error = "mail_list" ; var tfld = trim(document.mail_list.mail_inp) ; var emailfilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ; var illegalchars = /[\(\)\<\>\,\;\:\\\"\[\]]/ ; if ( document.mail_list.mail_inp.value =="" ) { alert ("Please fill in the damn form"); vaild = false; }else if (!emailfilter.test(tfld)) { alert ("Please use the right syntex email@email.com"); vaild = false; }else if (document.mail_list.mail_inp.value.match(illegalchars)){ alert ("Sorry there has been a error, Please retype your email") vaild = false; } return error; } Code (markup): This is the form. <div id="mail"> <div id="bar"> <img src="img/mailback.png" alt="" /> </div> <form id="mailinglist" name="mail_list" method="post" onsubmit="return validate_form();" action="mailform.php"> <label for="mailinp"></label> <input id="mailinp" name="mail_inp" type="text" /> <input class="mailsub" type="submit" value="Send" /> </form> </div> Code (markup): Thanks any help would be appreciated .
I think you need to change that last line to: if (!vaild) return false; else return true; Code (markup):
Thanks i am still new to all this. I tried both of the ideas still no luck. Here is what I have now. function vailidate_form () { vaild = true; var error = "" ; var tfld = trim(nav.mail.mail_list.mail_inp) ; var emailfilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ; var illegalchars = /[\(\)\<\>\,\;\:\\\"\[\]]/ ; if ( tfld.value =="" ) { alert ("Please fill in the damn form"); vaild = false; }else if (!emailfilter.test(tfld)) { alert ("Please use the right syntex email@email.com"); vaild = false; }else if (tfld.value.match(illegalchars)) { alert ("Sorry there has been a error, Please retype your email") vaild = false; } if (!vaild) return false; else return true; } Code (markup): <div id="mail"> <div id="bar"> <img src="img/mailback.png" alt="" /> </div> <form id="mailinglist" name="mail_list" method="post" onsubmit="return validate_form();" action="mailform.php"> <label for="mailinp"></label> <input id="mailinp" name="mail_inp" type="text" /> <input class="mailsub" type="submit" value="Send" /> </form> </div> Code (markup):
Still have a typo. You're calling: onsubmit="return validate_form();" but your function declaration is: function vailidate_form () See the typo?