前端之家收集整理的这篇文章主要介绍了
esui控件validatebox 通过正则判断输入 json传值,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
<td>
@Html.TextBoxFor(m => m.ActualInvoiceFee,new
{
@id = "txtActualInvoiceFee",@style = "width:80px",@class = "easyui-validateBox",@validType = @"VerifyMoney[{'maxVal':999999,'minVal':-999999},'只能输入数字']",@required = "true",@missingMessage = "必须填写发票金额"
})
</td>
//add by gongth验证金额
$.extend($.fn.validateBox.defaults.rules,{
VerifyMoney: {
validator: function (value,param) {
var reg = /^(|[+-]?(0|([1-9]\d*)|((0|([1-9]\d*))?\.\d{1,2})){1,1})$/;
value = value.Trim();
if (reg.test(value)) {
var maxVal = param[0]['maxVal'];
var minVal = param[0]['minVal'];
if (maxVal != null) {
if (reg.test(maxVal)) {
if (value > maxVal) {
$.fn.validateBox.defaults.rules.VerifyMoney.message = "超出范围";
return false;
}
}
}
if (minVal != null) {
if (reg.test(minVal)) {
if (value < minVal) {
$.fn.validateBox.defaults.rules.VerifyMoney.message = "超出范围";
return false;
}
}
}
return true;
} else {
$.fn.validateBox.defaults.rules.VerifyMoney.message = param[1];
return false;
}
},message: ''
}
});
//end ageReg