timmah1 Posted May 4, 2009 Share Posted May 4, 2009 After replacing the < with <, my form no longer validates. Can anybody tell me why this is? My form tag <form action="quote.php" method="post" enctype="application/x-www-form-urlencoded" name="quote" onsubmit="return validate();"> Here is the code <script type="text/javascript"> function validate() { if (document.quote.first_name.value.length < 1) { alert("Please enter your first name."); return false; } if (document.quote.last_name.value.length < 1) { alert("Please enter your last name."); return false; } if (document.quote.email.value.length < 7) { alert("Please enter your email address."); return false; } if (document.quote.zip.value.length < 5) { alert("Please enter a 5 digit zip code."); return false; } if (document.quote.phone1.value.length < 3) { alert("Please enter a valid phone number."); return false; } if (document.quote.phone2.value.length < 3) { alert("Please enter a valid phone number."); return false; } if (document.quote.phone3.value.length < 4) { alert("Please enter a valid phone number."); return false; } if (document.quote.age.value.length < 2) { alert("Please enter your gender and age."); return false; } return true; } </script> Thank you in advance Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 4, 2009 Share Posted May 4, 2009 Why did you change < to <? Quote Link to comment Share on other sites More sharing options...
timmah1 Posted May 4, 2009 Author Share Posted May 4, 2009 So that it would be validated http://validator.w3.org Without that, it would not validate Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 4, 2009 Share Posted May 4, 2009 Can you put back the < symbol? Quote Link to comment Share on other sites More sharing options...
the182guy Posted May 4, 2009 Share Posted May 4, 2009 The reason it stopped working is because < is not valid javascript syntax. Try putting the <script> block into the <head> section of the page and see if it validates with the < symbol. Quote Link to comment Share on other sites More sharing options...
timmah1 Posted May 4, 2009 Author Share Posted May 4, 2009 It is in the head I fixed it putting comment tags in <script type="text/javascript"> <!-- function validate() { if (document.quote.first_name.value.length <1) { alert("Please enter your first name."); return false; } if (document.quote.last_name.value.length <1) { alert("Please enter your last name."); return false; } if (document.quote.email.value.length <7) { alert("Please enter your email address."); return false; } if (document.quote.zip.value.length <5) { alert("Please enter a 5 digit zip code."); return false; } if (document.quote.phone1.value.length <3) { alert("Please enter a valid phone number."); return false; } if (document.quote.phone2.value.length <3) { alert("Please enter a valid phone number."); return false; } if (document.quote.phone3.value.length <4) { alert("Please enter a valid phone number."); return false; } if (document.quote.age.value.length <2) { alert("Please enter your gender and age."); return false; } return true; } // --> </script> [/code Works perfect now! Thanks for all the help 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.