转自:http://blog.sina.com.cn/s/blog_608475eb0100h3h1.html
官网地址:http://bassistance.de/jquery-plugins/jquery-plugin-validation
修改版文件下载:Validate
解决重复Name只验证第一个控件的问题:
1、解决验证问题:
将elements节中的
// 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; }
修改为:
// select this element if this has the same name as one in cache (may be was dynamically added) if (this.name in rulesCache) { if (!validator.objectLength($(this).rules())) { $(this).rules('add', rulesCache[this.name]); } return true; } if (!validator.objectLength($(this).rules())) { return false; }