The noob has returned.
Generally, if I want to do form validation I use the following format:
Code:
function validateForm(myForm)
{
if (failure conditions)
{
show error message;
return false;
}
return true;
}
<form onsubmit="return validateForm(this);"></form>
However, someone once told me it should be done like this:
Code:
function validateForm(myForm)
{
if (failure conditions)
{
show error message;
}
myForm.submit();
}
<form onsubmit="validateForm(this); return false;"></form>
I don't quite get the logic behind the second one. It looks like it forces the user to turn on Javascript to submit the form. That gives me bad vibes.
What are your thoughts?