Bootstrap整合ASP.NET MVC验证、jquery.validate.unobtrusive

没什么好讲的,上代码:

(function ($) {
    var defaultOptions = {
        validClass: 'has-success',
        errorClass: 'has-error',
        highlight: function (element, errorClass, validClass) {
            $(element).closest(".form-group")
                .removeClass(validClass)
                .addClass(errorClass);
        },
        unhighlight: function (element, errorClass, validClass) {
            $(element).closest(".form-group")
            .removeClass(errorClass)
            .addClass(validClass);
        }
    };

    $.validator.setDefaults(defaultOptions);

    if ($.validator.unobtrusive) {
        $.validator.unobtrusive.options = {
            errorClass: defaultOptions.errorClass,
            validClass: defaultOptions.validClass
        };
    }
})(jQuery);

 

jQuery Validation Unobtrusive Native

https://johnnyreilly.github.io/jQuery.Validation.Unobtrusive.Native/Home/GettingStarted.html

你可能感兴趣的:(Bootstrap整合ASP.NET MVC验证、jquery.validate.unobtrusive)