日期:2014-05-16  浏览次数:20394 次

jquery.validate.js 相同name的多个元素只能验证第一个元素的解决办法
动态生成的相同name的元素验证只会取第一个.
很恼火的问题.只有将jquery.validate.js中的对相同name的元素判断注释掉.
但是不知道会不会引起其他地方的BUG
希望以后jquery.validate.js能做针对元素ID进行验证而不仅仅针对元素name验证.



方法:
将484行的代码注释掉即可
// 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 only the first element for each name, and only those with rules specified
				/*if ( this.name in rulesCache || !validator.objectLength($(this).rules()) ) {
					return false;
				}*/