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 ...
随机推荐
- OpenJDK 阅读源代码 Java 实现字节流输入类
Java 的输入输出总是给人一种非常混乱的感觉.要想把这个问题搞清楚.必须对各种与输入输出相关的类之间的关系有所了解. 仅仅有你了解了他们之间的关系.知道设计这个类的目的是什么.才干更从容的使用他们. ...
- AIDL介绍和实例讲解
前言 为使应用程序之间能够彼此通信,Android提供了IPC (Inter Process Communication,进程间通信)的一种独特实现: AIDL (Android Interface ...
- iframe滚动条问题:显示/隐藏滚动条
iframe 问题2008-01-22 16:37****** 显示 iframe 内容 XHTML 1.0 Transitional 标准不能显示 <!DOCTYPE html PUBLI ...
- WindowState注意事项
本文将分析具体WindowState个别关键的成员变量和成员函数. Window #3 Window{20dd178e u0 com.android.mms/com.android.mms.ui.Co ...
- c# winform panel 流式布局 panel块可自动排列
代码下载地址 http://download.csdn.net/detail/simadi/7677053
- S2SH新手框架结构的准备工作只需要导入这些文件
实习北京最近一直在某公司.时间很冲突,总想着有事找东西坐,思想,做事先成套我吧 一套完整的东西想好主题,术去实现了,在学校尽管说是学了J2EE,可是确实没学到东西,Struts2+Hibernate不 ...
- Mysql 5.6 新特性
随笔,真的随笔,以后理解得更深了再修改. Index Condition Pushdown 更多的让存储引擎去处理Where语句中的条款,避免返回无关字段数据等: Multi-Range Re ...
- 也可以看看GCD(杭州电2504)(gcd)
也可以看看GCD Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total S ...
- BZOJ 2435 NOI2011 道路建设 BFS/DFS
标题效果:给定一个树(直接将树.不要贪图生成树图!).寻找每条边权值*分差的两侧之间 BFS水必须是能 竟DFS能够住...系统堆栈可能有些不够,我们可以使用内联汇编手册中大型系统堆栈 详见代码 这个 ...
- 腾讯2014在广州站实习生offer经验(TEG-开发背景)
研究在过去的一年是linux 什么系统编程和网络编程.比较熟悉的语言c/c++,python只写一些测试client.是后台开发类,比方前面笔面的网易CC(面完hr后挂).大概3月15号就在腾讯 jo ...