I am basically loading content into a bootstrap modal, editing the information and validation it using jquery validator, then submitting it with an ajax request. Everything is working well so far, until I click on another item where the validation classes are still appearing. My question is, is there a way of removing the validator classes after closing the bootstrap modal? Please help
There is a resetForm
method you can use to set the state of the validator.
// on load of your dialog:
var validator = $('#myForm').validate();
validator.resetForm();
If you are using bootstrapvalidator, the following code will help to get rid of error elements
$("#editModal").on('hidden.bs.modal', function () {
//Removing the error elements from the from-group
$('.form-group').removeClass('has-error has-feedback');
$('.form-group').find('small.help-block').hide();
$('.form-group').find('i.form-control-feedback').hide();
});
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