chobo2
chobo2

Reputation: 85835

What jquery validate methods are in asp.net mvc 3?

I am looking at asp.net mvc 3.0 and how it uses unobtrusive javascript through the jquery.validate library.

I am having trouble on finding what validation methods are supported. I only can find that mvc 3.0 can used the jquery.validate remote.

Does this new way use still data annotations and is limited by the couple they have or does this use something completely different?

Thanks

Upvotes: 0

Views: 474

Answers (1)

Darin Dimitrov
Darin Dimitrov

Reputation: 1039120

Client-Side validation is enabled by default in ASP.NET MVC 3. It uses unobtrusive javascript implementation based on the jquery.validate plugin which is also included by default. Unobtrusiveness is achieved thanks to the new HTML5 data-* attributes which are automatically emitted by the standard HTML Helpers based on the model metadata. Client-side validation works out of the box for all standard attributes in the System.ComponentModel.DataAnnotations namespace including the [Remote] attribute (see example here). It will not work out-of-the-box with custom defined attributes deriving from ValidationAttribute or with IValidatableObject interface.

The following section in web.config controls client side validation:

<appSettings>
    <add key="ClientValidationEnabled" value="true" /> 
    <add key="UnobtrusiveJavaScriptEnabled" value="true" /> 
</appSettings>

Upvotes: 1

Related Questions