javascript - Using bootstrap modal to load different contents with jquery validations -
i'm using bootstrap model edit table values. works perfectly. when i'm using bootstrapvalidator plugin validate modal there's problem. problem when click edit first time , load model works normally. if click edit again in same page, validation errors belongs previous 1 still shows. screen shot displays here,
modal call
<a data-toggle="modal" data-target="#dealmodal" onclick="ajax_get_edit_data('.$id.');"></a>
validations
<script type="text/javascript"> $(document).ready(function () { $('#dealform') .bootstrapvalidator({ message: 'this value not valid', fields: { deal_description: { message: 'the deal discription not valid', validators: { notempty: { message: 'the deal discription required , can\'t empty' } } } } }) .on('success.form.bv', function(e) { // prevent form submission e.preventdefault(); // form instance var $form = $(e.target); // bootstrapvalidator instance var bv = $form.data('bootstrapvalidator'); // use ajax submit form data //$.post($form.attr('action'), $form.serialize(), function(result) { // console.log(result); //}, 'json'); }); </script>
after form submitted, call resetform method:
... var bv = $form.data('bootstrapvalidator'); ... // after successful post bv.resetform();
Comments
Post a Comment