我使用jquery.validate.js和jquery-1.9.1.js进行验证,它在所有浏览器中都运行良好但在Ie7中没有运行
以下是我的代码
<script type="text/javascript" src="/scripts/jquery-1.9.1.js"></script>
<script type="text/javascript" src="scripts/jquery.validate.js"></script>
<script type="text/javascript" src="scripts/rwQueryString-1.0.jquery.min.js"></script>
<script>
$(function () {
var ruleSet_default = {
required: true
};
var ruleSet1 = {
minlength: 2,
maxlength: 20,
customvalidation: true
};
$.extend(ruleSet1, ruleSet_default); //combines defaults into 1
var ruleSet2 = {
email: true
};
$.extend(ruleSet2, ruleSet_default); // combines default into 2
$("#customForm").validate({
//focusCleanup: true,
rules: {
"<%= txtFirstName.UniqueID %>": ruleSet1,
"<%= txtLastName.UniqueID %>": ruleSet1,
"<%= txtPosition.UniqueID %>": ruleSet_default,
"<%= txtEmail.UniqueID %>": ruleSet2,
"<%= txtCompanyName.UniqueID %>": ruleSet_default,
"<%= txtCompanyAddress.UniqueID %>": ruleSet_default,
"<%= txtCity.UniqueID %>": ruleSet_default,
"<%= txtProvince.UniqueID %>": ruleSet_default,
"<%= txtCountry.UniqueID %>": ruleSet_default,
"<%= txtPostalCode.UniqueID %>": ruleSet_default
},
highlight: function (element) {
$(element).addClass("error");
$(element).removeClass("OK");
},
unhighlight: function (element) {
$(element).removeClass("error");
$(element).addClass("OK");
},
messages: {
"<%= txtFirstName.UniqueID %>": {
required: "Please, enter a name",
minlength: $.format("Keep typing, at least {0} characters required!"),
maxlength: $.format("Whoa! Maximum {0} characters allowed!")
},
"<%= txtLastName.UniqueID %>": {
required: "Please, enter last name",
minlength: $.format("Keep typing, at least {0} characters required!"),
maxlength: $.format("Whoa! Maximum {0} characters allowed!")
},
"<%= txtPosition.UniqueID %>": "Please, enter your position",
"<%= txtEmail.UniqueID %>": {
required: "Please, enter your email",
email: "Your email address must be in the format of name@domain.com"
},
"<%= txtCompanyName.UniqueID %>": "Please, enter your company name",
"<%= txtCompanyAddress.UniqueID %>": "Please, enter your company address",
"<%= txtCity.UniqueID %>": "Please, enter your city",
"<%= txtProvince.UniqueID %>": "Please, enter your province",
"<%= txtCountry.UniqueID %>": "Please, enter your country",
"<%= txtPostalCode.UniqueID %>": "Please, enter your zip code"
}
});
$.validator.addMethod("customvalidation",
function (value, element) {
return /^[A-Za-z\d=#$%@_ -]+$/.test(value);
},
"Sorry, no special characters allowed"
);
});
</script>
尝试在IE7中运行此错误时出现此错误
0x80020003 - JavaScript runtime error: Member not found. in jquery-1.9.1.js
但是当我注释掉jquery-validate.js代码时,jquery-1.9.1.js在IE7中不会产生任何问题。
请帮忙,因为我最近几天都被困在这里。
由于
答案 0 :(得分:0)
Jquery 1.9和更新的版本不支持IE6 / 7/8,好吧,它可能有用,但不能保证。
使用jquery 1.8.3它支持旧浏览器,包括Opera 9