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 ...
随机推荐
- 理解 JavaScript 回调函数并使用
JavaScript中,函数是一等(first-class)对象:也就是说,函数是 Object 类型并且可以像其他一等对象(String,Array,Number等)一样使用.它们可以"保 ...
- 关于js的回调函数的一点看法
算了一下又有好几个月没写博客了,最近在忙公司android的项目,所以也就很少抽时间来写些东西了.刚闲下来,我就翻了翻之前看的东西.做了android之后更加感觉到手机端开发的重要性,现在做nativ ...
- javascript中的感叹号 "!"
JavaScript中会经常遇到一个操作符:! 这是一个布尔操作符,用于将操作的值强制转换为布尔值并取反.常用场景如下: //条件判断中使用 var a; var b=null; if(!a){ co ...
- asp.net mvc4 简单的服务器监控开发之C#获取服务器CPU、RAM、TCP等系统信息(上)
一.背景 前段时间服务器出了点问题,加上学业愈来愈紧张,写博文分享的时间越来越少.虽然不是第一次在博客园上写经验,但是近期分享的博文得到了不少的朋友支持和指正,在这里内心非常感激和开心.希望以后能认真 ...
- 国内git项目托管平台
以前一直使用github托管项目,最近换了阿里云的vps,连接github出奇的慢,找了一下国内的代码托管平台. 有几个都不错,我刚好有csdn的账号,就试了一下csdn的托管平台,创建一个项目,发现 ...
- windows中LNK文件打开方式恢复(每日一修(1))
相信有些用户曾试过错误地把LNK文件的打开方式更改其他文件,导致系统所有的快捷方式都失效.在vista与Windows7系统还不普遍使用的时候,相信大家会有点惊慌失措,不要紧,下面只要大家进行如下操作 ...
- 看完这篇让你对各种前端build工具不再懵逼!
本文原标题为:我终于弄懂了各种前端build工具 译者:@Christian 译文:https://www.sdk.cn/news/5412 原文:https://medium.freecodecam ...
- Web应用请求和响应 HTTP相关
(1)请求:浏览器以HTTP协议的方式提交请求到服务器 (2)响应:服务器以HTTP协议的方式响应内容到浏览器 注意:HTTP是WEB大众化非安全协议 HTTPS是WEB安全协议,是基于HTTP协议的 ...
- JavaScript工具代码
html编码 function htmlEscape(sHtml){ return sHtml && sHtml.replace(/[<>&"]/g, f ...
- linux下配置yun源
备份原yum源 /etc/yum.repos.d/centos一base.repo 下载yum源 wagt 源网址/源名称/etc/yum.repos.d/原yum名