2010-04-06 55 views
1

我有一些使用單選按鈕定價的選項。 當用戶選擇沒有值的單選按鈕時,我的複選框表單不能被驗證。 這裏是我的代碼:如何使用jquery刪除驗證類?

選項:

<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 

複選框:

<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> 
+0

我看不懂。 – 2010-04-06 10:13:04

回答

0

你可以改變這一點:

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

要這樣:

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

required允許一個偏差表達式而不是真正的。在這種情況下,如果未檢查#pricing_imp_rect4,則僅需要You can read more about the dependency expression option here

+0

工作就像一個魅力!謝謝Nick – InnateDev 2010-04-06 12:45:15