Client side validation linked to the Business object

Client side validation linked to the Business object

Old forum URL:

kiddo85 posted on Thursday, February 23, 2012


I'm trying to implement client side validation in an MVC application and I was wondering if there is an easy way to do that? I saw a lot of forum posts about this topic, but they were all old so I decided to post a new one to see the latest news Smile

Have a great day!

JonnyBee replied on Thursday, February 23, 2012

You still must base your rules on the


and transform these descriptions into client side rules.


RockfordLhotka replied on Thursday, February 23, 2012

If you can express all your rules as data annotation attributes (System.ComponentModel.DataAnnotations) then you can simplify this process.

Data annotations are honored by (executed by) CSLA, so they run on the server, in Windows Forms, WPF - every platform, even Android.

Data annotations are also honored by MVC 3 and MVC 4. The built-in ones from Microsoft automatically cause javascript to be generated and sent to the browser to run the rules on the client. It is my understanding (though I've never done this) that you can write javascript for your custom attributes too, and that javascript will be sent to the browser automatically.

This does require that you write the rule twice - once in .NET and once in javascript - but at least you have a framework for the rules.

If you go down this road, I would very much like to hear your experiences - especially in terms of any complexity (or ease) in creating the javascript rule implementations within the context required by data annotations and MVC.

jpmir replied on Tuesday, November 27, 2012


I've found a pretty straight forward tutorial on how to do this kind of stuff:

Copyright (c) Marimer LLC