Jquery验证与浏览器IE不兼容

时间:2014-03-07 07:54:09

标签: javascript jquery internet-explorer internet-explorer-8 jquery-validate

以下代码适用于除IE以外的所有浏览器。我需要解决它。

$(function () {

    // Setup form validation on the #register-form element
    $("form[name=firstform]").validate({
        // Specify the validation rules
        rules: {
            username: {
                required: true,
                alpha: true
            },
        },
        messages: {
            username: {
                required: "Please Provide Your Name",
                alpha: "Name Should contains only alphabets",
            },
        },
        submitHandler: function (form) {
            form.submit();
        }
    });
});

与IE合作进行此类jquery验证的人是否可以帮助我解决这个问题?

1 个答案:

答案 0 :(得分:1)

尝试删除代码中的尾随逗号:

$(function () {

    // Setup form validation on the #register-form element
    $("form[name=firstform]").validate({
        // Specify the validation rules
        rules: {
            username: {
                required: true,
                alpha: true
            } // Here
        },
        messages: {
            username: {
                required: "Please Provide Your Name",
                alpha: "Name Should contains only alphabets" // Here
            } // Here
        },
        submitHandler: function (form) {
            form.submit();
        }
    });
});