开发者

How to require fields if a certain radio button is checked with jQuery Validate?

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');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜