jquery 验证数值大小

jquery 验证数值大小



慕妹3146593
浏览 410回答 1
1回答

呼如林

简单实现代码如下:$("#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 "));
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JQuery