I am trying to use reset form using bootstrap authentication
When I click on reset, it deletes the input values, but when I click on the "Send" button, even when the input is empty, it still sends when it should show an error.
Here is 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'); });
source share