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 rulesoption:
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 ...
随机推荐
- Mysql基本语句的总结
1---------------创建一个表------------------------------------ drop table if exists 表名 create table 表名( ...
- anaconda
python 集成环境 anaconda的使用 https://www.zhihu.com/question/35757251
- python学习之路 第三天
1.set集合:去掉重复字段 set.difference()找出不同并创建一个新的集合,不改变原来集合: set.difference_update() 改变原来集合,剔除掉括号内容: set.di ...
- 如何将本地项目与coding.net/github上的项目绑定
得到coding.net/github项目的ssh协议地址 形如:·git@git.coding.net:wzw/leave-a-message.git· 在本地生成公钥 输入 ssh-keyge ...
- sublime
sublime的格式化快捷键 其实在sublime中已经自建了格式化按钮:Edit -> Line -> Reindent 只是sublime并没有给他赋予快捷键,所以只需加上快捷 ...
- css3学习--border
http://blog.sina.com.cn/s/blog_61671b520101gelr.html border-radius border-radius: 50px 20px;上下都是50px ...
- 洗牌算法Fisher_Yates原理
1.算法 http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle 简单的原理如下图所示: 2.原理 总结下,洗牌算法Fisher_Yates ...
- Apache服务器网站访问伪静态内页出现No input file specified.的完美解决方案
原文地址:Apache服务器网站访问伪静态内页出现No input file specified.的完美解决方案 启用REWRITE的伪静态功能的时候,首页可以访问,而访问内页的时候,就提示:&quo ...
- iconfont使用,亲测
iconfont对于前端应用来说有很多便捷: 1.自由变化大小 2.自由修改颜色 3.可以添加一些视觉效果如:阴影.旋转.透明度. 4.兼容IE6 在线引用和下载到本地两种方法 一.在线引用 图标的制 ...
- Fixing DSDT
https://clover-wiki.zetam.org/Fixing-DSDT#dsdt-mask_fixdisplay_0100-bit-8