ASP.NET MVC3 Client-Side Validation with alert

2019-08-06 04:41发布

问题:

is there a way out of the box to display the client side validation message through an alert instead of span?

Thanks...

回答1:

It's just the jQuery validator, so you should be able to do the usual:

if (jQuery.validator) {
    jQuery.validator.setDefaults({
        showErrors: function (errorMap, errorList) {
            // do stuff
        }
    });
}