twitter.bootstrap.mvc icon indicating copy to clipboard operation
twitter.bootstrap.mvc copied to clipboard

Do not use a custom unobrusive validation script

Open fsateler opened this issue 11 years ago • 1 comments

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);

fsateler avatar Apr 26 '13 21:04 fsateler

Seconded. This approach works much better.

MattHoneycutt avatar Sep 16 '13 20:09 MattHoneycutt