未捕获的SyntaxError:意外的令牌 - 找不到不可见的字符

时间:2013-11-27 21:46:58

标签: javascript jquery google-chrome syntax

继续收到此错误。我检查了隐藏的字符,删除和重新输入的行等,但无济于事。这个隐藏角色可能是什么想法?我在另一个文件中使用几乎完全相同的代码。谢谢!

$('#register-manager').validate({
        rules:{
            company-company_name: {
            required: true
        },
        user-first_name: {
            required: true
        },
         user-last_name: {
            required: true
        },
         user-email: {
            required: true,
            email: true
        },
         user-password1: {
            required: true,
            min: 8
        },
         user-password2: {
            required: true
        }
    },
    messages: {
         company-company_name: {
            required: "Please enter your company's name."
        },
         user-first_name: {
            required: "Please enter your first name."
        },
        user-last_name: {
            required: "Please enter your last name."
        },
         user-email: {
            required: "Please enter your email.",
            email: "Please enter a valid email."
        },
         user-password1: {
            required: "Please enter your password.",
            min: "Please enter at least 8 characters."
        },
         user-password2: {
            required: "Please verify your password."
        }
    },
    submitHandler: function (form) { 
        form.submit();
    }
});

1 个答案:

答案 0 :(得分:5)

没有隐藏的角色(据我所知)。问题出现在错误消息中:

  

意外的令牌-

JS中的标识符不能包含-个字符,请尝试将它们包装在这样的引号中:

$('#register-manager').validate({
    rules:{
        "company-company_name": {
        required: true
    },
    "user-first_name": {
        required: true
    },
    ...