大佬教程收集整理的这篇文章主要介绍了javascript – 如何使用jQuery Validator比较两个字段,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我是否需要添加自定义方法,还是只在范围方法中使用变量名称?如果是这样,你能指点我的语法吗?
var validateSection = function (theForm) { $(theForm).validate({ rules: { startPoint: { required: true,range: [0,100] },endPoint: { required: true,range: [startPoint + 1,100] //Is this possible if I set the function to run on any change to either field? },} }); if ($(theForm).valid()) { return true; } else { return false; } }
$.validator.addMethod("endGreaterThanBegin",function(value,element) { return endPoint > startPoint },"* End Point Should be Greater than Start"); var validateSection = function (theForm) { $(theForm).validate({ rules: { startPoint: { required: true,100] },endPoint: { required: true,range: [1,100],endGreaterThanBegin: true },} }); if ($(theForm).valid()) { return true; } else { return false; } }
在我开始构建之前获取$.validator是未定义的,然后当我开始测试输入字段时,validateSection不是一个函数
以上是大佬教程为你收集整理的javascript – 如何使用jQuery Validator比较两个字段全部内容,希望文章能够帮你解决javascript – 如何使用jQuery Validator比较两个字段所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。