开发者

Forcing all controls on MVC2 form to validate using JQuery

Is there a way (using JQuery or Java Script) to force an MVC2 form to perform validation on it's fields with Data Annotation valid开发者_如何学编程ation without posting back to the server?

I have a MVC2 form that is quite complex. Many of the fields are hidden or displayed depending on other selections. Given this, some of the fields are validated using Data Annotations and some are validated using custom JQuery.

In the case that one of the fields with custom validation fails it's validation I wish to prevent the form from posting back however this stops any of the fields with Data Annotation Validation from working.

Thanks.


IMHO mixing jquery validate with MSAjax is a bad thing. For complex forms with many custom validation rules I would recommend using only jquery validate and on the server a more powerful validation framework than DataAnnotations such as FluentValidation.NET which works nicely with ASP.NET MVC.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜