I'm using the code below with the jQuery Validate plug-in, h开发者_Python百科owever I'm receiving the following error after clicking outside of one of the fields that should be required when "Canada" is checked. Any ideas?
province: {
depends: function(element) {
return $("input[name='country'][value='ca']").is(':checked')
}
},
$.validator.methods[method] is undefined [Break On This Error] eval(function(p,a,c,k,e,d){e=function(...x5b|trigger|x21|x23'.split('|'),0,{}))
$('#checkbox').click(function() {
if ($(this).is(':checked')) {
$('#element').rules('add', {
//rules
});
}
When you click on the checkbox to check the result, you can add the rules manually.
Not sure if this is your problem but your missing a semi-colon on this line
return $("input[name='country'][value='ca']").is(':checked');
精彩评论