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[\'input:radio[name=yes_no]\', \'Yes or no\']'">Yes

<input class="easyui-validatebox" type="radio" name="yes_no" value="0">No

 

posted @ 2019-04-03 17:08  猪脚踏浪  阅读(353)  评论(0编辑  收藏  举报