EasyUI 1.3.1以下的组合验证

时间:2022-01-08 18:55:49

适用于EasyUI 1.3.1以下的, 1.3.2已经自带组合验证(如validType:['validator1','validator2'])

$.extend($.fn.validatebox.defaults.rules, {
//支持多重验证, 使用如data-options="validType:'multiple[\'float\',\'SmallerThan\']'":
multiple: {
validator: function (value, vtypes) {
var returnFlag = true;
var opts = $.fn.validatebox.defaults;
for (var i = 0; i < vtypes.length; i++) {
var methodinfo = /([a-zA-Z_]+)(.*)/.exec(vtypes[i]);
var rule = opts.rules[methodinfo[1]];
if (value && rule) {
var parame = eval(methodinfo[2]);
if (!rule["validator"](value, parame)) {
returnFlag = false;
this.message = rule.message;
break;
}
}
}
return returnFlag;
}
}
}