开发者

How do I remove a validate class using jquery?

开发者 https://www.devze.com 2022-12-26 00:31 出处:网络
I have some options for pricing using radio buttons. When a user selects the radio button with no value my checkbox form must not be validated.

I have some options for pricing using radio buttons. When a user selects the radio button with no value my checkbox form must not be validated. here is my code:

Options:

<input type="radio" name="pricing_option_rect" id="pricing_imp_rect1" checked="checked" value="100">100
<input type="radio" name="pricing_option_rect" id="pricing_imp_rect2" value="200">200
<input type="radio" name="pricing_option_rect" id="pricing_imp_rect3" value="300">300
<input type="radio" name="pricing_option_rect" id="pricing_imp_rect4" value=开发者_开发问答"0" />0

Checkboxes:

<input type="checkbox" value="check1" name="rectcat[]" class="{validate:{required:true, minlength:1, maxlength:5}}" />One
<input type="checkbox" value="check2" name="rectcat[]" />Two
<input type="checkbox" value="check3" name="rectcat[]" />Three
<input type="checkbox" value="check4" name="rectcat[]" />Four
<input type="checkbox" value="check5" name="rectcat[]" />Five
<input type="checkbox" value="check6" name="rectcat[]" />Six
<input type="checkbox" value="check7" name="rectcat[]" />Seven
<input type="checkbox" value="check8" name="rectcat[]" />Eight
<div class="container">
  <label for="rectcat[]" class="error">
    Please Select a Minimum of ONE and a Maximum of FIVE categories!
  </label>
</div>


You can change this:

class="{validate:{required:true, minlength:1, maxlength:5}}"

To this:

class="{validate:{required:'#pricing_imp_rect4:unchecked', minlength:1, maxlength:5}}"

required allows a depdency expression instead of just true. In this case, it's only required if the #pricing_imp_rect4 isn't checked. You can read more about the dependency expression option here.

0

精彩评论

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