Reputation: 4597
I am using this plugin http://code.google.com/p/bvalidator/
$('#vendorDetailsForm').bValidator();
if ( $('#vendorDetailsForm').data('bValidator').isValid() ) {
$("#addVendorsTabs").tabs('select', 4);
}
The above logic is bind to a button that is nested inside vendorDetailsForm element, but i want to disable the submit action upon validation is successfull, and instead navigate to tab in index 4.
Currently it navigate to index 4, but then it submit the form!
Is there a way to do that?
Upvotes: 0
Views: 630
Reputation: 25137
jQuery's preventDefault is your best option, so it works more consistently across browsers.
$("#submit").submit(function(evt) {
...
evt.preventDefault(); // prevent default behavior of the event, in this case form submission
return false; // return false, just in case, but in theory is not necessary
});
Upvotes: 1
Reputation: 5265
You should put a return false
at the end of the function triggered by the submit
button.
For e.g.
$("#submit").submit(function() {
$('#vendorDetailsForm').bValidator();
if ($('#vendorDetailsForm').data('bValidator').isValid()) {
$("#addVendorsTabs").tabs('select', 4);
}
return false;
});
Upvotes: 0