I'm using bootstrap form validation, and i want to validate my form using a button that is not inside the form tags.
The reasons i want to do that are:
I don't want to redirect the user to other page or reload the current page, after submiting the form.
I want to call to an ajax call that register a user and return an answer (fail/success).
How can I call the validate form mechanism and getting true or false in order to know if I can redirect to the ajax call.
Thank you.
Just attach a jquery click event to the button outside the form tags and inside that function do someting along the lines of:
//1) Submit Form using Form's ID
$("#testForm").submit();
//2 Submit Form using Form's Name
$("form[name='myForm']").submit();
//3 Submit Form using Form's Index.
$("form:first").submit();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With