jzaefferer/jquery-validation — Issue #268: Highlight/unhighlight parent element of multiple fields
Author: SysmicWave
Created: 2011-11-29 09:20:58+00:00
State: open

Hi,

I had an issue whereby I wanted to highlight the parent DIV of multiple elements if validation failed.

I achieved this easily with:

highlight: function(element) {
$(element).closest("div").addClass("highlightError");
}

However, my issue arose when one of the fields in the DIV was correct. This meant that the highlight completely disappeared, even if other errors still remained.

To fix this I moved the unhighlight IF statement in the defaultShowErrors() function above the highlight FOR loop in the defaultShowErrors() function.

Now the highlighting remains until all fields in the parent element are correct.

I'm not sure if anyone is interested in this, I just thought i'd share it.

Cheers