jquery.validate1.13
jquery.validate新的写法(jquery.validate1.13.js)
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
<script src="../js/jquery.js"></script><script src="../js/jquery.validate.js"></script><script> $().ready(function() { $("#registerForm").validate(); });</script> <form id="registerForm" method="get" action=""> <fieldset> <p> <label for="cusername">用户名</label> <input id="cusername" name="username" type="text" data-rule-required="true" data-rule-rangelength="[2,10]" data-msg-required="用户名不能为空" data-msg-rangelength="用户名长度必须是2到10个字符"> </p> <p> <label for="cpassword">密码</label> <input id="cpassword" name="password" type="password" data-rule-required="true" data-rule-minlength="6" data-msg-required="密码不能为空" data-msg-minlength="至少设置6位密码"> </p> <p> <label for="cconfirmpassword">确认密码</label> <input id="cconfirmpassword" name="confirmpassword" type="password" data-rule-equalTo="#cpassword" data-msg-equalTo="两次密码不一致"> </p> <p> <label for="cemail">邮箱</label> <input id="cemail" name="email" data-rule-required="true" data-rule-email="true" data-msg-required="邮箱不能为空" data-msg-email="邮箱的格式不正确"> </input> </p> <p> <label for="chasreferee">有推荐人请勾选</label> <input type="checkbox" id="chasreferee" name="hasreferee"> </p> <p> <label for="creferee">推荐人</label> <input id="creferee" name="referee" data-rule-required="#chasreferee:checked" data-msg-required="推荐人不能为空"> </input> </p> <p> <input type="submit" value="提交"> </p> </fieldset></form> |
看了之前的别人写的文章,貌似是依赖jquery.metadata.js这个库,然后写的时候以 class=”required email” 这样的形式来写,这样写起来好像有些乱,class本身是呈现样式的,现在被附上各种校验的规则,看上去似乎有些乱,不过好在新版本中,又有了新的写法,不依赖上面的js库,以 data-rule-验证规则、data-msg-提示信息 这样的格式来重新定义,更简单,更直观,更强大了。上面的测试通过
我的版本的jquery.validate1.13.js
然后这样的写法,控件中的messages不会生效,还会报错:Cannot read property 'call' of undefined 园子里面很多jquery.validate文章提到可以使用,我看是版本过时了,反正我没有试验出来。还有就是将验证卸载class里面我也是醉了。下面的测试错误!
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title><script type="text/javascript" src="jquery.min.js"></script><!--<script type="text/javascript" src="jquery.validate.js"></script>--><script type="text/javascript" src="jquery.validate1.13.js"></script><script type="text/javascript" src="jquery.validate.message_cn.js"></script><script type="text/javascript" src="jquery.metadata.js"></script><script type="text/javascript">$(function(){ $.metadata.setType("attr", "validate"); $("#signupForm").validate(); //$("#signupForm").validate({ meta: "validate" }); //$("#commentForm").validate();})</script></head><body><form id="signupForm" method="get" action=""> <p> <input id="email" name="email" validate="{required:true, email:true, messages:{required:'输入email地址', email:'你输入的不是有效的邮件地址'}}" /> </p> <p> <input class="submit" type="submit" value="Submit"/> </p></form></body></html> |
jquery.validate1.13的更多相关文章
- jquery.validate新的写法(jquery.validate1.13.js)
<script src="../js/jquery.js"></script> <script src="../js/jquery.vali ...
- jQuery的13个优点
1.轻量级 JQuery非常轻巧,采用Dean Edwards编写的Packer压缩后,大小不到30KB,如果使用Min版并且在服务器端启用Gzip压缩后,大小只有18KB. gzip: 每天一个li ...
- JS 循环遍历JSON数据 分类: JS技术 JS JQuery 2010-12-01 13:56 43646人阅读 评论(5) 收藏 举报 jsonc JSON数据如:{"options":"[{
JS 循环遍历JSON数据 分类: JS技术 JS JQuery2010-12-01 13:56 43646人阅读 评论(5) 收藏 举报 jsonc JSON数据如:{"options&q ...
- jquery.validate1.9.0前台验证使用
一.利用jquery.form插件提交表单方法使用jquery.validate插件 现象:当提交表单时,即使前台未验证通过,也照常提交表单. 解决办法: $('#myForm').submit(fu ...
- jQuery与ajax 基础运用
jQuery是一个轻量级js框架,使用方便快捷,更是封装ajax处理方法,如$.load() $.get() $.post() 等 但最常用的方法还是$.ajax() 一.一般的格式为 $.ajax( ...
- jQuery插件之validation插件
前面的话 最常使用javascript的场合就是表单的验证,而jQuery作为一个优秀的javascript库,也提供了一个优秀的表单验证插件——Validation.Validation是历史最悠久 ...
- jQuery使用简单示例 validate 插件
摘录自:http://blog.csdn.net/u010320371/article/details/51104783用户登录 用户名 密码 确认密码 <!DOCTYPE html> & ...
- jquery.validate.js表单验证
一.用前必备官方网站:http://bassistance.de/jquery-plugins/jquery-plugin-validation/ API: http://jquery.bassist ...
- jQuery.Validate验证库详解
一.用前必备官方网站:http://bassistance.de/jquery-plugins/jquery-plugin-validation/ API: http://jquery.bassist ...
随机推荐
- A WPF File ListView and ComboBox
源码下载: Download FileListView_Version_2.zip Download FileListView_Version_2_Binaries.zip Download File ...
- Java 的swing.GroupLayout布局管理器的使用方法和实例(转)
The following builds a panel consisting of two labels in one column, followed by two textfields in t ...
- TFS(Team Foundation Server)简介和新手入门
在两部分的文章.我会介绍Team Foundation Server一些核心功能,着重于产品的日常应用是如何将这些功能结合使用. 作为一个软件开发.在我的职业生涯,.我常常用于支持软件开发过程中大量的 ...
- jQuery 操作 input 之 checkbox
jQuery 操作 input 之 checkbox 一片 HTML 清单: <input type="checkbox" name="hobby" va ...
- Andoird实现类似iphone AssistiveTouch的控件的demo
类似Iphone Assistive Touch的控件的实现 网上也有些这方面的控件,不过貌似不怎么好用,或者是论坛需要积分下载,恰好自己在项目中有用到这种控件,就打算自己写一个,也成功实现了这种功能 ...
- poj Firing(最大重量封闭图)
Firing 题目: 要解雇一些人,而解雇的这些人假设人跟他有上下级的关系,则跟他有关系的人也要一起解雇.每一个人都会创造一定的价值,要求你求出在最大的获利下.解雇的人最小. 算法分析: 在这之前要知 ...
- UVA 11402 - Ahoy, Pirates!(段树)
UVA 11402 - Ahoy, Pirates! 题目链接 题意:总的来说意思就是给一个01串,然后有3种操作 1.把一个区间变成1 2.把一个区间变成0 3.把一个区间翻转(0变1,1变0) 思 ...
- 【cocos2d-js官方文档】二十五、Cocos2d-JS v3.0中的单例对象
为何将单例模式移除 在Cocos2d-JS v3.0之前.全部API差点儿都是从Cocos2d-x中移植过来的,这是Cocos2d生态圈统一性的重要一环.可惜的是,这样的统一性也在非常大程度上限制了C ...
- SQL Server -减少代码触发的负担
触发器是一张表的增删改操作,引起或触发对还有一张表的增删改操作,所以触发器便有3种类型.各自是deleted触发器.Update触发器,insert触发器 触发器又依据替换原来的增删改操作,还是在原来 ...
- Android setDisplayOptions 具体的使用说明
Android有几个地方使用位计算.实例Intent Flags,它们的定义View onMeasure(int widthMeasureSpec, int heightMeasureSpec),并且 ...