简体   繁体   中英

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.

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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM