最近碰到了一个棘手的问题 juqery.validate插件在火狐和谷歌下都能使用 IE下无效的问题.JS也没报错。
在网上查了很多资料都无果.后来看到别人写的一篇文章找到了解决办法
把juqery.validate.js中elements方法
return $([]).add(this.currentForm.elements)
.filter(":input")
.not(":submit, :reset, :image, [disabled]")
.not( this.settings.ignore )
.filter(function() {
!this.name && validator.settings.debug && window.console && console.error( "%o has no name assigned", this);
// 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;
rulesCache[this.name] = true;
return true;
});
找到上面的方法
修改为:
1 return $(':input',this.currentForm)
2 .not(":submit, :reset, :image, [disabled]")
3 .not( this.settings.ignore )
4 .filter(function() {
5 !this.name && validator.settings.debug && window.console && console.error( "%o has no name assigned", this);
6
7 // select only the first element for each name, and only those with rules specified
8 if ( this.name in rulesCache || !validator.objectLength($(this).rules()) )
9 return false;
10
11 rulesCache[this.name] = true;
12 return true;
13 });
问题暂时解决。不知道会不会产生其它的错误