I am using JQuery Validation. Now I want my rules to be invoked only when certain condition is satisfied, namely, I want $(\"#AppSelectField\").is(\':hidden\')
This should do it:
$(function() {
var checkIfFieldVisible = function() {
return !$("#AppSelectField").is(':hidden');
};
$("#RequestLock").validate({
rules: {
FloorNum: {
required: { depends: checkIfFieldVisible },
digits: { depends: checkIfFieldVisible }
}, // <-- EXTRA COMMA
},
message: {
FloorNum: "The floor number must be integer",
}, // <-- EXTRA COMMA
});
});
(I marked some extra commas you have on your code, as they will make IE choke)