开发者

ASP.NET MVC 3 and jQuery validation

What is the best way to do validation in MVC 3? Here are the requirements:

  1. Works client 开发者_如何学Cand server side.
  2. Shares as much code between client and server as possible (attribute on model property seems ideal)
  3. Works across async request
  4. Display errors, validation messages, and success messages coming from the server side
  5. Unobtrusive javascript, as minimal as possible
  6. Dynamically added HTML should still validate the same way

My task this weekend is to build a robust solution for this, figured I'd ask here first before re-inventing or re-discovering the wheel with blood sweat and tears.


I would check out Brad Wilson's blog on this. He covers using unobtrusive validation in MVC3, sounds like exactly what you're looking for.

Adding more info per OP's comment

Regarding server side validation (custom validation), check out @jfar's response to a similar question I posted regarding custom validation -- he suggests that you should question your design if you're relying heavily on custom validation. In my case, I ended up going either with Ajax to handle my custom validation, or allowed the postback to perform the validation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜