大致结构是:

<script type="text/javascript" src="<%=path %>/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="<%=path %>/js/jquery.validate.min.js"></script>

<script>

$(function(){
jQuery.validator.addMethod("string", function(value, element) {
return this.optional(element) || !(/\<|\>|\'|\"|\\/g.test(value));
}, "不允许包含特殊字符!");

jQuery.validator.addMethod("isBlank", function(value, element) {
return $.trim(value) != ''
}, "必填!");

// 表单验证
var vForm = $("#form_SMS").validate({
rules : {
'account' : {
isBlank: true,
},
'passwd' : {
isBlank: true,
},
'signature' : {
isBlank: true,
},
'totalSendLimit' : {
digits: true,
},
'dailyMaxSend' : {
digits: true,
},
'memberDailyMaxRecv' : {
digits: true,
max: 99
},
'memberDailyMaxRepl' : {
digits: true,
max: 9
},
'captchaTempletNo' : {
isBlank: true,
},
'testSMSTempletNo' : {
isBlank: true,
}
},
messages : {
'account' : {
isBlank : "必填",
},
'passwd' : {
isBlank : "必填",
},
'signature' : {
isBlank : "必填",
},
'totalSendLimit' : {
digits : "请输入整数!",
},
'dailyMaxSend' : {
digits : "请输入整数!",
},
'memberDailyMaxRecv' : {
digits : "请输入整数!",
max: "输入值不能大于 99!",
},
'memberDailyMaxRepl' : {
digits : "请输入整数!",
max: "输入值不能大于 9!",
},
'captchaTempletNo' : {
isBlank : "必填",
},
'testSMSTempletNo' : {
isBlank : "必填",
}
}
});

</script>

其中,“string” “isBlank ”是自己扩展的方法。方法定义后,在规则中就能被使用。

这里像account都是input的name值,与id值无关。如果验证失效了,应该就是name值发生改变了。

jQuery Validate验证(项目中使用的)的更多相关文章

  1. 弹出框页面中使用jquery.validate验证控件

    弹出框页面中使用jquery.validate验证控件有几个问题需要解决: 1,弹出框的提交事件完成后如何关闭弹出框页面? 2,提交不成功如何返回当前页? 3,如果知道验证事件成功? 之前笔者都是JS ...

  2. jQuery Validate验证框架详解

    转自:http://www.cnblogs.com/linjiqin/p/3431835.html jQuery校验官网地址:http://bassistance.de/jquery-plugins/ ...

  3. 【转】jQuery Validate验证框架详解

    jQuery校验官网地址:http://bassistance.de/jquery-plugins/jquery-plugin-validation 一.导入js库 <script type=& ...

  4. jQuery Validate验证框架详解(转)

    jQuery校验官网地址:http://bassistance.de/jquery-plugins/jquery-plugin-validation 一.导入js库 <script type=& ...

  5. jQuery Validate验证框架与 jQuery ajaxSubmit的联合使用

    jQuery Validate验证框架自定义验证 第一步导入导入js库 <script src="<%=basePath%>static/js/jquery.js" ...

  6. 修改jQuery.validate验证方法和提示信息

    1.添加验证方法 在jquery.validate.js文件中直接添加验证方法,例如: jQuery.validator.addMethod("Specialstring", fu ...

  7. atitit.jQuery Validate验证框架详解与ati Validate 设计新特性

    atitit.jQuery Validate验证框架详解与ati Validate 设计新特性 1. AtiValidate的目标1 2. 默的认校验规则1 2.1. 使用方式 1.metadata用 ...

  8. jQuery Validate验证框架详解(jquery.validate.min.js)

    原博客 jQuery Validate验证框架详解 jQuery校验官网地址:https://jqueryvalidation.org/ 一.导入js库 <script type="t ...

  9. JQuery validate验证规则

    //定义中文消息 var cnmsg = { required: “必选字段”, remote: “请修正该字段”, email: “请输入正确格式的电子邮件”, url: “请输入合法的网址”, d ...

  10. jquery.validate 验证机制

    jquery.validate 验证机制 金刚 juqery juqery.validate 在开发系统时,使用了jquery.validate.js 这个验证插件,来校验数据合法性 重点 验证是以i ...

随机推荐

  1. query ajax总是进入error回调函数

    query ajax总是进入error回调函数今天纠结了1小时,ajax总是进入了error函数中.平时使用从来没有出现过这种现象,纠结了半小时. 最后稍微总结出了点: 1.以前使用都是服务器端输出S ...

  2. 数据库-mongodb-常用命令

    展示当前集合列表 1 show dbs 查看查询命令 1 db.stu.find().explain(); 结果中的 "cursor":"BasicCursor" ...

  3. .NET平台开源JSON库LitJSON的使用方法

    下载地址:LitJson.dll下载 一个简单示例: String str = "{'name':'cyf','id':10,'items':[{'itemid':1001,'itemnam ...

  4. HDU 4342

    先确定M的大致范围后即可求. #include <iostream> #include <cstdio> #include <algorithm> #include ...

  5. layer iframe加载单个图片或者加载页面

    加载单个图片 layer.open({ type: , title: false, closeBtn: , area: '150px', skin: 'layui-layer-nobg', //没有背 ...

  6. android开发一些小bug

    1.一定要注意findViewId这种方法,尤其是含有多个同样的R.id的名字时,debug时不会当场报错.但随后会报空指针错误 2.List转换为Array能够这样处理: ArrayList< ...

  7. 高校学生学籍系统C++&amp;mysql

    /* C++程序设计实践教学环节任务书 一.题目:高校学籍管理系统 二.目的与要求 1. 目的: 1.掌握C++语言基本知识及其编程方法  2.掌握类和对象的基本概念与用法 3.掌握面向对象中的继承与 ...

  8. 浅谈Model1 VS Model2

    在学习drp的过程中就对model1和model2产生了浓厚的兴趣,一直都没有好好总结下,接下来就和大家一起学习下它们的真面目. 一.是什么? 首先大家提到model想到了什么?它的名词意识是:模型: ...

  9. Swift - 制作一个在线流媒体音乐播放器(使用StreamingKit库)

    在之前的文章中,我介绍了如何使用 AVPlayer 制作一个简单的音乐播放器(点击查看1.点击查看2).虽然这个播放器也可以播放网络音频,但其实际上是将音频文件下载到本地后再播放的. 本文演示如何使用 ...

  10. maven的pom.xml配置标签

    转自:https://blog.csdn.net/wf787283810/article/details/76188595 <project xmlns="http://maven.a ...