I'm trying to specify a couple of custom methods for highlighting/ unhighlighting valid/invalid fields on my form, but I'm getting some strange behaviour, which I'm not sure is due to me misunderstanding how these methods are supposed to be implemented, or if it's just buggy.
$().ready(function() { // validate signup form on keyup and submit $("#contactForm").validate({ showErrors: function(errorMap, errorList) { $("#result").html('<span class="errors"></span><span class="msg">Please check/fill the marked fields</span> !'); this.defaultShowErrors(); }, highlight: function(element, errorClass) { $(element.form).find("label[for=" + element.id + "]").addClass (errorClass); }, unhighlight: function(element, errorClass) { $(element.form).find("label[for=" + element.id + "]").removeClass (errorClass); }, rules: { name: "required", email: { required: true, email: true } } }); }); My problem is when some of inputs in invalid, then the label will take the "error" class, will be turn on red, when I correct the content of input my label disapear, I have also the "valid" class, in my css file, what colud be the problem I hope You understand what I mean;