jQuery Validation plugin can generate two types of labels, one with class=”error” and the other has class=”error valid”.
I have the following code to detect the existence of labels with class=”error”:
($form.find("label.error").not($form.find("label.valid")).length == 0);
Is there any other better (ie. more optimized) way doing this? Thanks.
Try something like this
$('div.error:not(.valid').css('background-color', 'red');as seen in this jsFiddle