v0.5.3 is released on 2014.11.05!
By default, after pressing the submit button, the plugin will validate fields and then submit the form if all fields are valid.
If you use a custom submit handler, the form might be submitted more than one time.
To prevent the plugin from submitting the form automatically, you can trigger the success.form.bv event:
$(document).ready(function() {
$(form)
.bootstrapValidator({
... options ...
})
.on('success.form.bv', function(e) {
// Prevent form submission
e.preventDefault();
// You can get the form instance
var $form = $(e.target);
// and the BootstrapValidator instance
var bv = $form.data('bootstrapValidator');
// Do whatever you want here ...
// Use the defaultSubmit() method if you want to submit the form
// See http://bootstrapvalidator.com/api/#default-submit
bv.defaultSubmit();
});
});You can use a custom submit handler like the following way:
$(document).ready(function() {
$(form)
.bootstrapValidator({
... options ...
})
.on('success.form.bv', function(e) {
// Prevent form submission
e.preventDefault();
});
// Custom submit handler
$(form).submit(function(e) {
// You can get the form instance
var $form = $(e.target);
// and the BootstrapValidator instance
var bv = $form.data('bootstrapValidator');
// Do whatever you want here ...
});
});