Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC3 check is valid form in view [duplicate]

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

like image 579
ShaneKm Avatar asked Mar 29 '11 11:03

ShaneKm


2 Answers

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

like image 116
archil Avatar answered Sep 19 '22 15:09

archil


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.

like image 31
DalSoft Avatar answered Sep 22 '22 15:09

DalSoft