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
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.