jQuery checkbox validation

后端 未结 1 1964
囚心锁ツ
囚心锁ツ 2021-01-03 05:08

I\'m using the jQuery code below to validate a form. Now it all works great but I would like for the checkbox validation to use the .validator rather than its c

相关标签:
1条回答
  • 2021-01-03 05:43

    Here is some code that will work with the JQuery Validation Plugin. I'm not sure if this will work with what you're using because I've never heard of it.

    $("#request-form").validate({
        rules: {
            checkbox: { 
            required: 'input[type="checkbox"]:checked',
            minlength: $('input[type="checkbox"]').length()
            }
        },
        messages: {
            checkbox: "Please check at least one.",
        }
    });
    

    HTH

    0 讨论(0)
提交回复
热议问题