Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I disable "eager" validation entirely using jquery validate?

Is there a way to disable "eager" validation using the jquery.validate plugin? Either through an option in the script or as a hack? "Eager" validation kicks in once the form has been validated once - after that, invalid fields are validated onfocusout. I want to disable this behavior, and change my forms to only be validated when the submit button is pressed.

I don't mind hacking through the validate script itself also, so if that's what the solution requires that's acceptable.

like image 374
Kevin Jhangiani Avatar asked Apr 25 '10 01:04

Kevin Jhangiani


People also ask

What is eager validation?

By default, the plugin validates input when the submit button is clicked. The behavior is "lazy" in order to be unobtrusive to the user. If an error is found, the validation then becomes "eager" and validates input as the user corrects the offending entries.

What is validate in JQuery?

Form validation is a process of confirming the relevant information entered by the user in the input field. Here we will be validating a simple form that consists of a username, password and a confirmed password using jQuery.

What is Javascript validation plugin?

jQuery Validation is a javascript based plugin that helps you implement a powerful client side validator to your form elements that validate the value ( name, email, address, etc..) your user input when submitting.


1 Answers

Check out the onfocusout option.

onfocusout, boolean, default:true

"Validate elements (except checkboxes/radio buttons) on blur. If nothing is entered, all rules are skipped, except when the field was already marked as invalid."

About halfway down.

So to disable "eager" validation:

$(".selector").validate({
  onfocusout: false
});
like image 182
GlenCrawford Avatar answered Oct 22 '22 17:10

GlenCrawford