I am trying to reset the form using bootstrap validator
When i click on reset, its removing the input values, but when i click submit even when the input is empty, its still submitting, when it should be showing an error
Here is the js
$('#shortener').bootstrapValidator({
container: '#sstatus',
fields: {
url: {
validators: {
notEmpty: {
message: 'Enter a url!'
},
uri: {
message: 'URL is not a valid url, include http://'
}
}
}
}
}).on('success.form.bv', function(e) {
// Prevent form submission
e.preventDefault();
console.log('in');
// Get the form instance
var $form = $(e.target);
// Get the BootstrapValidator instance
var bv = $form.data('bootstrapValidator');
// Use Ajax to submit form data
$.post('ajax/new_url.php', $form.serialize(), function(result) {
console.log('works'+result.message);
$('#shortener').fadeOut('fast', function(){
$form.bootstrapValidator('resetForm', true);
});
$(document).on('click', '#shorten_again', function(e){
e.preventDefault();
});
}, 'json');
});
$('form').bootstrapValidator('resetForm', true);
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