I have a problem with bootstrap, validate and data-loading-text. When you click on save and not all fields are correct the button must be reset "$('#save').button('reset');". Also "This field is required." is put on the field. I do this by "error.insertAfter(element);" See the code below on validate.
Everything is working one time. When I click the second time on the save button (still the field not filled in) the button is not reset anymore.
How can I solve this?
<button type="submit" id="save" name="save" value="ok" class="btn btn-success btn-fill btn-wd" data-loading-text="<i class='fa fa-spinner fa-spin'></i> SAVING"> SAVE</button>
<script>
$('#save').on('click', function() {
var $this = $(this);
$this.button('loading');
});
</script>
...
<script>
$(document).ready(function () {
var $validator = $("#new").validate({
rules: {
test: {
required: true,
}
},
errorPlacement: function(error, element) {
$('#save').button('reset');
error.insertAfter(element);
},
});
}
</script>