Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is triggering Unobtrusive Validation check in asp.net MVC 3

I'm trying to figure out how unobtrusive validation works in asp.net mvc 3.

I would like to know what is triggering the validation check when I click to submit the form. How is the script jquery.validate.unobtrusive.js bound to the form submit event ?

I also would like to know how can I manually prevent/trigger this check.

like image 320
Arno 2501 Avatar asked Dec 20 '12 08:12

Arno 2501


1 Answers

jquery.validate.unobtrusive is a validator for jquery.validate. It is like a extension.

jquery.validate.unobtrusive implements all the events and jquery.validate use it.

You can look into the jQuery.validate.js file and see that it uses the submit of the form.

// validate the form on submit
this.submit( function( event ) {
   ...

If you want to trigger the validation by yourself you can call

$("#myform").valid()
like image 153
dknaack Avatar answered Nov 15 '22 09:11

dknaack