jquery validate 详解一
来源:互联网 发布:怎么给网络加密 编辑:程序博客网 时间:2024/05/17 09:14
详解一 jQuery校验
官网地址:http://bassistance.de/jquery-plugins/jquery-plugin-validation一导入js库
<script src="../js/jquery.js"type="text/javascript"></script>
<script src="../js/jquery.validate.js"type="text/javascript"></script>
二、默认校验规则
(1)required:true
(2)remote:"check.php"
(3)email:true
(4)url:true
(5)date:true
(6)dateISO:true
(7)number:true
(8)digits:true
(9)creditcard:
(10)equalTo:"#field"
(11)accept:
(12)maxlength:5
(13)minlength:10
(14)rangelength:[5,10]
(15)range:[5,10]
(16)max:5
(17)min:10
三、默认的提示
messages: {
},
如需要修改,可在js代码中加入:
jQuery.extend(jQuery.validator.messages, {
});
推荐做法,将此文件放入messages_cn.js中,在页面中引入
<script src="../js/messages_cn.js"type="text/javascript"></script>
四、使用方式
1.将校验规则写到控件中
<scriptsrc="../js/jquery.js"type="text/javascript"></script>
<script src="../js/jquery.validate.js"type="text/javascript"></script>
<script src="./js/jquery.metadata.js"type="text/javascript"></script>
$().ready(function() {
});
<form id="signupForm" method="get"action="">
</form>
使用class="{}"的方式,必须引入包:jquery.metadata.js
可以使用如下的方法,修改提示内容:
class="{required:true,minlength:5,messages:{required:'请输入内容'}}"
在使用equalTo关键字时,后面的内容必须加上引号,如下代码:
class="{required:true,minlength:5,equalTo:'#password'}"
2.将校验规则写到js代码中
$().ready(function() {
});
//messages处,如果某个控件没有message,将调用默认的信息
<form id="signupForm" method="get"action="">
</form>
required:true必须有值
required:"#aa:checked"表达式的值为真,则需要验证
required:function(){}返回为真,表时需要验证
后边两种常用于,表单中需要同时填或不填的元素
- jquery validate 详解一
- jquery validate 详解一
- jquery validate 详解一
- jquery validate 详解一
- jquery validate 详解一
- jquery validate 详解一
- jquery validate 详解一
- jquery validate 使用详解一
- jquery validate 详解一
- jquery validate 详解一
- jquery.validate 使用详解
- jquery validate 详解
- jquery validate 详解二
- jquery validate 详解二
- jquery validate 详解
- jquery validate 详解
- jQuery.validate使用手册,详解
- jQuery.validate插件详解
- 实现一个挺高级的字符匹配算法: 给一串很长字符串,要求找到符合要求的字符串,例如目的串:123 1******3***2 ,12*****3 这些都要找出来
- 好吧,CSS3 3D transform变换,不过如此!
- java中equals和==的区别
- JSP中include指令和include动作区别详解
- Mutex
- jquery validate 详解一
- linux和window文件共享 安装samba
- java虚拟机------常量池介绍
- android 常用控件 (AutoCompleteTextView) (MultiAutoCompleteTextView)
- linux和window文件共享 安装samba
- Transform 基础知识
- 好用的velocity
- 连锁储值卡、会员卡、配送相关
- Ext 学习