I am using jQuery Validate () plugin. It works very well, however, I would like a hightlight input that has an error in it AFTER SERVING. I tried:
$(".selector").validate({
highlight: function(element, errorClass, validClass) {
$(element).addClass(errorClass).removeClass(validClass);
$(element.form).find("label[for=" + element.id + "]")
.addClass(errorClass);
},
unhighlight: function(element, errorClass, validClass) {
$(element).removeClass(errorClass).addClass(validClass);
$(element.form).find("label[for=" + element.id + "]")
.removeClass(errorClass);
}
});
... on the page http://docs.jquery.com/Plugins/Validation/validate#options , but I cannot get it to work. Do I need to create errorClass and validClass css? Does he know which element in some way? I lost a little.
Thanks for the ideas.
EDIT: Perhaps I need to study my question more closely! I have a field in which there is spam equal to 12, but if the user places it at 11, the form tells me that there is an error, but does not highlight the input that has the error. He will tell me that it is necessary, but do not show it if the answer is wrong ... any thoughts ??