Jump to content

[SOLVED] From won't validate


timmah1

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/156818-solved-from-wont-validate/
Share on other sites

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.