Reputation: 706
I have a tabbed form with 6 fields. 3 fields are active on each tab when any tab is clicked and the fields in other tab gets style display:none
. How to validate the fields with style display:none
?
Upvotes: 0
Views: 460
Reputation:
You need to tell the validator to ignore nothing(hidden fields, display none fields).
ignore:''
will do it.
$("#formId").validate({
ignore : '',
rules : {
...
},
messages : {
...
}
});
Upvotes: 2
Reputation: 504
You can declare then use the function:
jQuery.expr[':'].hiddenByParent = function(a) {
return jQuery(a).is(':hidden') && jQuery(a).css('display') != 'none';
};
to get the fields within hidden tabs.
Upvotes: 0
Reputation: 8062
if you are looking for just to check whether the element is visible or not than,
$(element).is(":visible") or
$(element).is(':hidden') or
$(element).css('display') == 'none'
will return if the element is hidden or not
Upvotes: 0