jquery 验证数值大小
1 回答
呼如林
TA贡献1798条经验 获得超3个赞
简单实现代码如下:
$("#rewardForm").validate({
rules: {
"reward": {
required: true,
digits:true,
balance:true,
checkBalance:true
}
}, messages:{
"reward":{
digits:" * 请填写正确的转账金额(应为数字)",
required:" * 请输入转账金额 "
}
}
});
jQuery.validator.addMethod("balance", function(value,element) {
var sumreward=$("#sumreward").val();
return this.optional(element) || value<= sumreward;
}, $.validator.format(" * 余额不足 "));
jQuery.validator.addMethod("checkBalance", function(value,element) {
var balance=0;
return this.optional(element) || value>balance;
}, $.validator.format(" * 转账金额必须大于0 "));
- 1 回答
- 0 关注
- 409 浏览
添加回答
举报
0/150
提交
取消