|
Answer» Hey guys,
I have a form with fields "name", "email", and "url". Very simple comments/suggestion form. I am trying to validate only two of the fields: name and email. The validation checked for the INPUT and returns alert pop-up BOX if the fields are empty:
function checkForm() {
var name = document.comment.name.value; var email = document.comment.email.value; var url = document.comment.url.value;
var valid = TRUE;
if(name == "") { alert("Fill in your name"); valid = false;
} if(email == "") { alert("Fill in your email (ex. [emailprotected])"); valid = false; }
return valid; }
Everything works, except that after I click on Ok button the form is still being sent. What could be the problem? Why does the form keeps submitting even THOUGHT the return boolean is false?
Note: I EXCLUDED the
|