1

我正在使用 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 中不会产生任何问题。

请帮忙,因为我最近几天被困在这里。

谢谢

4

1 回答 1

0

Jquery 1.9 和更新版本不支持 IE6/7/8,好吧,它可能工作但不能保证。

使用 jquery 1.8.3 它支持旧浏览器,包括 Opera 9

于 2014-11-08T11:08:54.993 回答