2014-09-02 98 views
0

你好,我有jquery驗證問題。當我有單選按鈕,像這樣隱藏jQuery驗證錯誤消息的單選按鈕不工作後添加自定義單選按鈕

<input name="umum_expectation" type="radio" value="1" required data-msg-required="Please select one" /> 1 <br/> 
<input name="umum_expectation" type="radio" value="2" />2<br/> 
<input name="umum_expectation" type="radio" value="3" />3<br/> 
<input name="umum_expectation" type="radio" value="4" />4<br/> 
<input name="umum_expectation" type="radio" value="5" />5<br/> 

<!-- handler show error--> 
<label for="umum_expectation" class="error"></label> 

錯誤處理程序,我用[用戶iChek單選按鈕>>https://github.com/fronteed/iCheck/

這個代碼定製

<script type="text/javascript"> 
      $(document).ready(function() { 
       $("input[type='radio']").iCheck({ 
       checkboxClass: 'icheckbox_square-blue', 
       radioClass: 'iradio_square-blue', 
       increaseArea: '20%' 
      }); 
      }); 
     </script> 

我之前[用戶單選按鈕,我按下提交按鈕而不檢查單選按鈕,顯示錯誤。然後我檢查單選按鈕,該錯誤可以自動隱藏

當前情況,當我按下提交按鈕而沒有檢查單選按鈕時,顯示錯誤。然後我檢查單選按鈕,錯誤不能自動隱藏。 這必須再次按提交按鈕來隱藏錯誤

那麼如何解決它之前,我定製單選按鈕的條件?對不起,我的英語

+0

你好,你有沒有找到這個解決方案? – 2017-02-22 09:58:01

回答

0

默認情況下,jQuery驗證忽略隱藏的輸入元素。

只需告訴插件沒有忽略隱藏的元素(這是發生了什麼,當你intialize I檢查):

$('form').validate({ 
    hidden:'', 
    //the rest of your options 
});