Considering the following very basic form:
<form action="action_page.php" method="post">
<input type="text" id="fname" name="fname"><br><br>
<input type="text" id="lname" name="lname"><br><br>
<input type="submit" value="Submit">
</form>
I know how to validate and submit this form using jquery ajax. My question: is there anyway I could first validate the form using ajax before submitting it the regular way to the action php file?
I mean the two processes should be the result of the submit action.. ie the script called should first validate and when all ok then submits the page to the file in the form action attribute or to any url I specify. Otherwise it halts form submit returning the error messages.
Thanks
submitevent listener usesevent.preventDefault()and sends an AJAX request to validate it. The AJAX callback function submits the form if the validation is successful.