Reputation: 20429
I use jQuery Validate plugin and would like to show all errors at one place. I have html like below:
<div class="modal-footer">
<p class="pull-left hide" id="register-result"></p>
</div>
and javascript:
$("#company").validate({
errorClass: "error",
errorElement: "div",
errorPlacement: function(error, element) {
$("#register-result").html(error);
$("#register-result").show();
},
...
It works almost as expected - the error message is displayed where needed. But when user fixed the error, error message is still displayed. How can I change it?
Upvotes: 1
Views: 119
Reputation: 2972
Make sure you include a success return.
success: function () {
$('#register-result').fadeOut();
}
Upvotes: 2
Reputation: 24526
$("#company").validate({
errorClass: "error",
errorElement: "div",
errorPlacement: function(error, element) {
$("#register-result").html(error);
$("#register-result").show();
},
success: function() {
$("#register-result").hide();
}
});
Upvotes: 1