jQuery Validation Callback Function
you to supply the invalid callback function which you can find documented here, like so
$(".selector").validate({
invalidHandler: function(form, validator) {
var errors = validator.numberOfInvalids();
if (errors) {
//resize code goes here
}
}
})
Alternatively, you can use the errorPlacement callback function in order to act on the specific element that failed validation. As an example, the code below uses the errorPlacement callback to set the class of each invalid form element's parent div tag to "error" and then removes the "error" class once the element passes validation :
form.validate({
rules: {
Name: {
required: true
},
Email: {
required: true
, regex: "^[0-9a-zA-Z.+_\-]+@{1}[0-9a-zA-Z.+_\-]+\\.+[a-zA-Z]{2,4}$"
}
},
messages: {
Name: {
required: "Please give us your name"
},
Email: {
regex: "Please enter a valid email address"
}
},
errorPlacement: function(error, element) {
element.parent().addClass("error");
},
success: function(element) {
$("#" + element.attr("for")).parent().removeClass("error");
}
});