jquery validate minlength rule is not working
Question:
I have a form with a password field. The password has to be at least 8 characters long.
<form action="/account/register" method="post" id="form-register">
<div class="input-row">
<input name="data[User][password]" type="password" id="FUserPassword" class="required" placeholder="Password">
</div> </form> $("#form-register").validate({
rules: {
FUserPassword : {
minlength:
}
}
});
It applies the "required" rule, but it just ignores the "minlength" rule.
What am I doing wrong? I'm using the same code (the JS part) on other pages and it works as expected.
Answer:
Validate looks for the name
of the input field, not the id
. From the documentation for the rules
option:
Key/value pairs defining custom rules. Key is the name of an element (or a group of checkboxes/radio buttons)
With that in mind, you should use something like this:
$("#form-register").validate({
rules: {
'data[User][password]': {
minlength:
}
}
});
For input names with special characters, be sure to quote the object key.
转自: http://stackoverflow.com/questions/14404884/jquery-validate-minlength-rule-is-not-working
jquery validate minlength rule is not working的更多相关文章
- ligerui的jquery.validate验证需要添加validate="{required:true,minlength:8,equalTo:'#newpassword'}"
ligerui的jquery.validate验证需要添加validate="{required:true,minlength:8,equalTo:'#newpassword'}"
- jQuery.validate errorPlacement
在被验证的控件的后一个元素控制显示 errorPlacement: function(error, element) { element.next().css("color",&q ...
- Jquery validate验证表单时多个name相同的元素只验证第一个的问题
下面搜集了五种方法,主要还是前两个提供了解决方案,第三种需要修改jQuery源码: 修复jquery.validate插件中name属性相同(如name='a[]')时验证的bug 使用jquery. ...
- jQuery Validate 表单验证 — 用户注册简单应用
相信很多coder在表单验证这块都是自己写验证规则的,今天我们用jQuery Validate这款前端验证利器来写一个简单的应用. 可以先把我写的这个小demo运行试下,先睹为快.猛戳链接--> ...
- jquery validate表单验证插件-推荐
1 表单验证的准备工作 在开启长篇大论之前,首先将表单验证的效果展示给大家. 1.点击表单项,显示帮助提示 2.鼠标离开表单项时,开始校验元素 3.鼠标离开后的正确.错误提示及鼠标移入时的帮 ...
- 表单验证插件之jquery.validate.js
提到表单验证的插件,第一个想到的就是jquery.validate.js,所以小生想在这里稍微详细地说一下这款插件的具体使用方法,便于理解,我直接附上整段demo的代码(没怎么调样式,主要是看js): ...
- jQuery Validate验证框架详解
转自:http://www.cnblogs.com/linjiqin/p/3431835.html jQuery校验官网地址:http://bassistance.de/jquery-plugins/ ...
- JS验证控件jQuery Validate
jQuery Validate 插件为表单提供了强大的验证功能,让客户端表单验证变得更简单,同时提供了大量的定制选项,满足应用程序各种需求.该插件捆绑了一套有用的验证方法,包括 URL 和电子邮件验证 ...
- jquery:validate的例子
该文档转载自 http://ideabean.javaeye.com/blog/363927 官方网站 http://bassistance.de/jquery-plugins/jquery-plug ...
随机推荐
- BPM问题
1.安装XFormDesigner后编辑界面报错 解决方法:
- [转] JAVA读取excel数据(插入oracle数据库)
原文地址:http://blog.csdn.net/zczzsq/article/details/16803349 本实例做的是读取execl(只能读取.xls的execl,即只能读取03版的),如果 ...
- [HTML5] ArrayBuffer与类型化数组
写在前面 这是关于JS二进制操作的第三篇博客,前两篇详见: [HTML5] Blob对象 [HTML5] FileReader对象 此前从宏观角度介绍了如何通过JS创建一个二进制对象,并介绍了如何将本 ...
- Wpf usercontrol dispose
窗口关闭时组件"析构": public UserControl() { InitializeComponent(); ...
- List Map Set 的用法和区别
参考 http://blog.csdn.net/vstar283551454/article/details/8682655
- Bzoj3041 水叮当的舞步
Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 132 Solved: 75 Description 水叮当得到了一块五颜六色的格子形地毯作为生日礼物 ...
- Android 热修复方案Tinker
转自:http://blog.csdn.net/l2show/article/details/53925543 Android 热修复方案Tinker(一) Application改造 Android ...
- 聊一聊PV和并发
最近和几个朋友,聊到并发和服务器的压力问题.很多朋友,不知道该怎么去计算并发?部署多少台服务器才合适? 所以,今天就来聊一聊PV和并发,还有计算web服务器的数量 的等方法.这些都是自己的想法加上一些 ...
- centos环境搭建
1.php -v 与phpinfo(); 不符,查看centos是否有自带的php:更改centos环境变量 /etc/profile,source /etc/profile生效: 2.pecl ...
- rootkit后门检查工具RKHunter
---恢复内容开始--- rkhunter简介: 中文名叫"Rootkit猎手", rkhunter是Linux系统平台下的一款开源入侵检测工具,具有非常全面的扫描范围,除了能够检 ...