I am having a problem understanding the return value on my form validation
I thought that with the following script:
That if my user entered invalid data and my function returned false that the forms page in question would halt the process and reload the page in question.Code:<form action="index.php" name="myform" onSubmit="return validate()">
The code in question:
If my user types in the wrong zipcode I get an error message using onblur() when the user leaves the field. But, they can still submit the form to index.php, which I definately don't want to happen.Code:function validate (divId, theValue, typeInfo){ //instantiate object var fvObj = new ValidatorObj(); if (typeInfo == "fName" || typeInfo == "lName"){ if(!validName(divId, theValue, fvObj)) return false; } else if (typeInfo == "address"){ if(!validAddress(divId, theValue, fvObj)) return false; } else if (typeInfo == "email"){ if(!validEmail(divId, theValue, fvObj)) return false; } else if (typeInfo == "phone"){ if(!validPhone(divId, theValue, fvObj)) return false; } else { if(!validZip(divId, theValue, fvObj)) return false; } }
Can someone give me a heads up on what I am missing? I ran an alert against validZip() and works the way it should.
Kevin



Reply With Quote

Bookmarks