您好,我有以下函数,仅当选中其他两个复选框之一时,我才需要使其返回 false。
$.validator.addMethod(
"ReutersNA",
function(value, element) {
var selectedCountry = $("#Country").val();
var NorthAmerica = new Array("USA","CAN","MEX");
if($.inArray(selectedCountry,NorthAmerica) > -1) {
return true;
} else return false;
}, "Cannot select Reuters News outside of North America."
);
I need to add if($("#IQBAS, #IQPRE").is(":checked") && the above function = return true
最佳答案
你的意思是这样的吗?
$.validator.addMethod(
"ReutersNA",
function(value, element) {
var selectedCountry = $("#Country").val();
var NorthAmerica = new Array("USA","CAN","MEX");
return ($("#IQBAS, #IQPRE").is(":checked") && $.inArray(selectedCountry,NorthAmerica) > -1);
},
"Cannot select Reuters News outside of North America."
);
关于javascript - 需要有关 inArray 的帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3225422/