I would really appreciate anyone\'s help with this as I just can\'t seem to get it working. I am using a javascript code to check my form before it is submitted. I check for
In the form tag there is a field onsubmit to specify your validation function. Something like that:
<form name="myForm" onsubmit="return validateForm()" method="post">
<!-- your inputs -->
</form>
You should use event.preventDefault();
in your if statement when you check for errors.
I you are clicking a submit button, first check all the fields, if something fails in your validation, raise event.preventDefault()
. With this, this will prevent the form to submit.
If there are no errors, the preventDefault
will not be raised and the form will be submitted.
Extra information: jQuery API