jQuery Validation plugin: validate check box

后端 未结 3 1848
长情又很酷
长情又很酷 2020-12-01 09:22

I am using jQuery Validation plugin to validate check box since it does not have default option, One should be selected and max two check boxes can be selected, these is the

3条回答
  •  一向
    一向 (楼主)
    2020-12-01 09:59

    There is the easy way

    HTML:

    x
    y
    z
    
    

    JQUERY:

    $("#submit").on("click",function(){
        if (($("input[name*='test']:checked").length)<=0) {
            alert("You must check at least 1 box");
        }
        return true;
    });
    

    For this you not need any plugin. Enjoy;)

提交回复
热议问题