jQuery Validate plugin conditional required field

前端 未结 1 1575
悲&欢浪女
悲&欢浪女 2021-01-04 22:01

I\'m having an issue with the jQuery validate plugin. I have a set of 3 radio buttons, if either of the first two are selected, the user is shown an extra s

1条回答
  •  佛祖请我去吃肉
    2021-01-04 22:31

    $("#job-earnings-salary:checked") returns a jQuery object which will always be truthy

    $("#client-form").validate({
      focusInvalid: false,
      ignore: [],
      rules: {
        salaryband: {
          required: function(element) {
            return $('#job-earnings-salary').is(':checked')
          }
        }
      }
    });
    
    
    
    
    
    Select Salary Band

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