jQuery Validate - at least one from a group of checkboxes is checked only if a radio button is checked

后端 未结 2 1825
生来不讨喜
生来不讨喜 2021-01-13 06:50

I´m using jquery validate plugin to ensure at least one from a group of three checkboxes is checked and it´s woking fine. But I want validate these checkboxes only if the ra

2条回答
  •  梦毁少年i
    2021-01-13 07:15

    You could try the built-in functionality:

    $( "#itemForm" ).validate({
      rules: {
        opt01: {
          required: "#resp01-sim"
        }
      }
    });
    

    http://jqueryvalidation.org/required-method/#example:-makes-details-required-only-if-#other-is-checked

提交回复
热议问题