开发者

MVC3 check is valid form in view [duplicate]

开发者 https://www.devze.com 2023-02-20 07:13 出处:网络
This 开发者_StackOverflowquestion already has answers here: Closed 10 years ago. Possible Duplicate:
This 开发者_StackOverflowquestion already has answers here: Closed 10 years ago.

Possible Duplicate:

MVC 3 - checking if form is valid (has passed client side validation)

Is there a way to check if unobtrusive validation did pass/form is valid?

I need to show an alert box if the form is not valid. how would i do it in mvc3? thanks


If you want to check for it in View on server side, you could use ViewData.ModelState.IsValid


if (!$('#id-of-your-form').valid())
   alert('Invalid');

Should do the trick, MVC validation makes use of jquery.validate.js which attaches to the form.

0

精彩评论

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

关注公众号