Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to retrieve a form's validator

What is the correct way to get the current jQuery validator object for an existing form?

Note, the validator is being configured using the jQuery Unobtrusive validation plugin hence why I don't have a reference to it.

like image 717
Ben Foster Avatar asked Jun 19 '12 17:06

Ben Foster


2 Answers

From documentation:

The validate method returns a Validator object

Next code will gets existing validator or init it

var validator = $("form_selector").validate(); 
like image 159
Anonymous Avatar answered Sep 30 '22 13:09

Anonymous


You want:

var validator = $("#form_id").data("validator");
like image 35
Andrew Whitaker Avatar answered Sep 30 '22 14:09

Andrew Whitaker