I have done various tests and I have found that the jQuery validate
function works only with the submit button.
Am I right? If yes how can I use the jQuery validate plugins without the submit button?
I have done various tests and I have found that the jQuery validate
function works only with the submit button.
Am I right? If yes how can I use the jQuery validate plugins without the submit button?
You can use the method valid() to invoke the validator directly.
It will return bool indicating whether the form is valid or not.
Here is an example, from jQuery documentation:
$("#myform").validate();
$("a.check").click(function() {
alert("Valid: " + $("#myform").valid());
return false;
});
When you call the validate
method on the jQuery validate plugin it returns an instance of Validator
which you should store. When you need to, you can call the form
or showErrors
methods on the Validator
instance to either validate the form, or validate the form and show the errors respectively.