Iurii Dziuban
Iurii Dziuban

Reputation: 1091

Validate form on the tab which is not selected

I use jQuery form validation plugin. I have got a webpage with "save" button and tabs. there is a form in one tab. Here is code for "save" button.

$("#save").click(function(){
        $("#optionalform").valid();
});

It validates form if the tab with "#optionalform" selected. If it is not selected validation doesn`t work.

Upvotes: 1

Views: 120

Answers (1)

Ryley
Ryley

Reputation: 21226

What you need to do is specify that hidden elements should not be ignored:

$("#optionalform").validate({
    ignore:''
});

The default for the ignore option is ':hidden' which includes all the elements of your form, except when that tab is visible.

See it in action here: http://jsfiddle.net/ryleyb/NfmWW/

Upvotes: 1

Related Questions