首页 > 代码库 > easyui-validatebox验证 radio

easyui-validatebox验证 radio

添加规则

$.extend($.fn.validatebox.defaults.rules, {        requireRadio: {              validator: function(value, param){                  var input = $(param[0]);                input.off(‘.requireRadio‘).on(‘click.requireRadio‘,function(){                    $(this).focus();                });                return $(param[0] + ‘:checked‘).val() != undefined;            },              message: ‘Please choose option for {1}.‘          }      });

 

使用方法

<input class="easyui-validatebox" type="radio" name="yes_no" value="1" data-options="validType:‘requireRadio[\‘#ff input[name=yes_no]\‘, \‘Yes or no\‘]‘">Yes<input class="easyui-validatebox" type="radio" name="yes_no" value="0">No