1
votes

I'm using JQuery Validation Plugin to validate a form and I wanted to turn off the auto validation for the fields when you type or tab out of the fields, so I added:

onkeyup: false, onfocusout: false

to the validate() options....but the problem is that I have one dropdown () and after the "required" rule has triggered and I select a value and tab to the next field, the error message for the dropdown disappears, which I don't want. I want the validation to only trigger when the visitor clicks "submit". Everything is working as expected for the input fields.

Please advise.

Thanks!

1

1 Answers

0
votes

It is written in the official docs, that there's another possible validation callback:

onclick

Type: Boolean or Function()

Validate checkboxes and radio buttons on click. Set to false to disable.

However, when I opened jquery.validate.js and looked at callbacks list, I saw in the comments, that click event is used to validate select fields as well.

The final code to disable auto validation:

$('form').validate({
    onclick: false,
    onkeyup: false,
    onfocusout: false
});