Open fsateler opened 11 years ago
There is no need to provide a script that may fall out of sync. jQuery.Validation provides a way to modify the behavior:
(function ($) { var defaults = $.validator.defaults, oldHighlight = defaults.highlight, oldUnhighlight = defaults.unhighlight; defaults.highlight = function (element, errorClass, validClass) { oldHighlight(element, errorClass, validClass); // Mark the parent controls as erroneous $(element).closest('.control-group').addClass('error'); }; validator.defaults.unhighlight = function (element, errorClass, validClass) { oldUnhighlight(element, errorClass, validClass); $(element).closest('.control-group').removeClass('error'); }; })(jQuery);
Seconded. This approach works much better.
There is no need to provide a script that may fall out of sync. jQuery.Validation provides a way to modify the behavior: