I want to allow users to add validation rules in the database, for example ‘Password cannot be the same as username’ or something like that. I know how to validate these rules server side, but I would like to have a set of validators available which can be set at runtime, and also work client-side.
I want to validation process to be handled as close to the MVC standard as possible. One thing that crossed my mind is to set attributes at runtime, but I’m not sure if this is the way to go.
For now, we have the validation working at runtime and pass validation messages back to the client using Json, which works fine, but requires a (async) postback. If we can implement client side validation, we can eliminate the validation postback which boosts the application’s performance but again, i’m not sure which way to go. Anyone with some good thoughts?
did you try remote validation attribute? if you need lookup in database, you need ajax.
http://msdn.microsoft.com/en-us/library/gg508808(v=vs.98).aspx