I understand that several months have passed, but I just had to deal with this problem myself, and I believe that I came up with a good solution.
Instead of decorating the tab containing the error in invalidHandler , use highlight and unhighlight handlers instead to properly highlight or highlight the tab containing the invalid entry. Unlike invalidHandler , which is not called until an attempt is made to send (or a manual call to check it), highlight and unhighlight called whenever an invalid field is processed, including onBlur.
jQuery('#Form').validate({ highlight: function(element, errorClass, validClass) { $(element).addClass(errorClass).removeClass(validClass); $('a[href=#' + $(element).parents('.ui-tabs-panel').attr('id') + ']').addClass(errorClass).removeClass(validClass); }, unhighlight: function(element, errorClass, validClass) { $(element).removeClass(errorClass).addClass(validClass); $('a[href=#' + $(element).parents('.ui-tabs-panel').attr('id') + ']').removeClass(errorClass).addClass(validClass); } });
In the above code for highlight and unhighlight I add and remove the corresponding errors and valid classes from the invalid element (default behavior), and then I use the (double) selector to get any <a /> that loads this element contains a div and I am adding or removing the same classes to this link. This code assumes that the contents of the tab are not loaded using AJAX, and the links that load the div have href for the div binding identifier. If your tab link configuration is different, you may have to tweak the selector a bit to suit your needs.
Update
After testing this, I also identified one trap that could reduce the legitimacy of the solution. Namely, this will remove the error class from the tab link, regardless of whether there are still invalid elements on this tab. Invalid items still remain selected, but the tab loses selection. I experimented with viable workarounds for this problem, and so far I have not found it. I will update this if / when I do this.
source share