ie7中的jQuery错误不是9

时间:2011-11-09 20:03:45

标签: jquery internet-explorer-7

我有一个表单的jQuery验证代码。但是,当我在开发人员工具中将ie9设置为ie7浏览器模式时,我收到错误并且验证不起作用。

我看不出可能出现什么问题?

错误就是单词消息上方的行}。

SCRIPT1028: Expected identifier, string or number 
confirm, line 587 character 25

代码是:

            $().ready(function() {

                // validate signup form on keyup and submit
                $("#signupForm").validate({
                    rules: {
                        'data[User][email]': {required: true, email: true},
                        'data[User][firstname]': {required: true},
                        'data[User][surname]': {required: true},
                        'data[User][address1]': {required: true},
                        'data[User][city]': {required: true},
                        'data[User][state]': {required: true},
                        'data[User][phone]': {required: true, digits: true},
                        'user_terms': 'required',
                        'data[User][card_type]': {required: true},
                        'data[User][card_number]': {required: true, creditcard: true},
                        'data[User][card_type]': {required: true},
                        'data[User][card_name]': {required: true},
                        'data[User][card_cvv]': {required: true,digits: true, minlength: 3, maxlength:3 },
                        'data[User][card_expires]': {required: true}


                    }, // This is the line ie7 complains about
                    messages: {
                        UserEmail: {required: "Please enter a valid email address"},
                        UserFirstname: {required: "Please enter your firstname"},
                        UserSurname: {required: "Please enter your lastname"},
                        UserAddress1: {required: "Please enter your Address"},  
                        UserCity:       {required: "Please enter your City"},
                        UserState:      {required: "Please enter your State"},
                        UserPhone:      {required: "Please enter your Phone"},
                        user_terms:         'You must agree to the terms and conditions',
                        UserCardType:       {required: "Please select your Card Type"},

                    },
                    errorPlacement: function(error, element) {
                            error.appendTo( element.parent().next() );
                    },
                    submitHandler: function() {
                        $('#checkoutBT').hide();
                        var $bookingNow = $('<div id="bookingNow" class="ui-button ui-widget ui-state-default ui-corner-all"><img src="https://www.treacyshotelwaterford.com/res360/res/app/webroot/images/forms/ajax-loader.gif" /> Booking Now</div>');
                        $('.checkout').append($bookingNow);
                        form.submit();
                    }

                });

1 个答案:

答案 0 :(得分:4)

IE往往会对数组和对象中的尾随逗号产生影响。将其从此行中删除:

 UserCardType:       {required: "Please select your Card Type"},