views:

328

answers:

2

Where can I find some good information on the new client-side validation functionality included in ASP.NET MVC v2?

I'd like to find information about using the client-side validation JavaScript without using DataAnnotations, and I'd like to find out how custom validations are handled.

For example, if I want to validate two fields together, how would I utilize the provided JavaScript? Or if I wanted to write validation code on the server-side that queried a database, how could I use the provided JavaScript to implement a similar validation?

I don't see any books on MVC2 yet, and the blog entries I've found are not detailed enough.

+2  A: 

DataAnnotations have limits. You can easily apply simple validation rules on independent model properties and enable client side validation but if you need to handle more advanced scenarios such as dependent properties you will need more robust frameworks such as Fluent Validation or xVal.

Darin Dimitrov
+1  A: 

Here's a 20-minute video demonstration.

10-4 Episode 37: Leveraging Model Metadata and Validation with ASP.NET MVC2

Posted By: Jonathan Carter | Jan 7th @ 11:21 AM

In this episode of 10-4, we discuss a new feature coming in the next release of ASP.NET MVC: model metadata and validation. This allows you to associate validation rules and metadata with your model and have the runtime perform validation automatically. In addition, you can also have JavaScript emitted that will provide client-side validation as well, making it dead simple to achieve a rich client and server validation experience with any web application.

Zack Peterson