1

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

Thanks...

1 Answer 1

2

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
        }
    });
}
Sign up to request clarification or add additional context in comments.

3 Comments

this works on the client side, but if I add an error to the ModelState on the server side it doesn't work. I guess there is no MVC3 OOB...
You'd need to (1) write CSS rules which hide the div returned by the server-side validations and (2) show it in an alert on $.ready(). That said, pages which show a browser-modal dialog on load are kind of obnoxious on a multi-tabbed browser.
This is an ASP.NET MVC project with multiple views for certain device types. This specific view is for the iPhone/iPod using the iWebKit. We're not worried about the alert being annoying.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.