<code style="margin: 0px; padding: 0px; border: 0px; font-size: 14px; vertical-align: baseline; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, serif; white-space: inherit"><span style="color: #666666; font-family: 微软雅黑; line-height: 24px;">1、将引入的插件:jquery.validate.js 第<span style="color: #666666; font-family: 微软雅黑; line-height: 24px;">484行的代码注释:<br/></span></span></code>
// select only the first element for each name, and only those with rules specified
//if ( this.name in rulesCache || !validator.objectLength($(this).rules()) ) { return false; }
2、页面中需要验证的输入框必须加上不同的id。
如:html中:
<form>
<input type='text' name='name' id='name1' val=''/>
<input type='text' name='name' id='name2' val=''/>
</form>
js:
var $form=$('form'),validator=$form.validate();
$.extend(validator.settings,{
rules:{
"name":'required'
}
});
以上就是解决jquery.validate.js 多个name相同验证处理的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号