隐藏jQuery验证错误消息的单选按钮不工作后添加自定义单选按钮

问题描述:

你好,我有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

默认情况下,jQuery验证忽略隐藏的输入元素。

只需告诉插件没有忽略隐藏的元素(这是发生了什么,当你intialize I检查):

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