jQuery错误 - SyntaxError:missing:属性id之后

时间:2022-12-21 15:38:23

I'm getting an error "SyntaxError: missing : after property id" in the following code.

我在以下代码中收到错误“SyntaxError:missing:after property id”。

jQuery("#username_update").validate({

        rules : {
            new-username : {
                required : true,
                email : true
            },
            retype-username : {
                required : true,
                email : true
            }
        },

        messages : {
            new-username : {
                required : "New User Name must be filled in"
            },
            retype-username : {
                required : "Retype User Name must be filled in"
            }
        }

    });

Error is occurring at rules : { new-username : { line. Any help?

规则发生错误:{new-username:{line。有帮助吗?

3 个解决方案

#1


5  

use

使用

"new-username" : {
                required : "New User Name must be filled in"
            }

instead of

代替

new-username : {
                required : "New User Name must be filled in"
            }

#2


6  

new-username is not valid property name. Quote it, or use underscore. Unqoted property name have to obey javascript identifier rules (alphanumeric plus underscore and dollar). Quoted property may be any string.

new-username不是有效的属性名称。引用它,或使用下划线。 Unqoted属性名称必须遵守JavaScript标识符规则(字母数字加下划线和美元)。引用属性可以是任何字符串。

#3


1  

You can not use "-" in the property name new-username. Use underscore...

您不能在属性名称new-username中使用“ - ”。使用下划线...

#1


5  

use

使用

"new-username" : {
                required : "New User Name must be filled in"
            }

instead of

代替

new-username : {
                required : "New User Name must be filled in"
            }

#2


6  

new-username is not valid property name. Quote it, or use underscore. Unqoted property name have to obey javascript identifier rules (alphanumeric plus underscore and dollar). Quoted property may be any string.

new-username不是有效的属性名称。引用它,或使用下划线。 Unqoted属性名称必须遵守JavaScript标识符规则(字母数字加下划线和美元)。引用属性可以是任何字符串。

#3


1  

You can not use "-" in the property name new-username. Use underscore...

您不能在属性名称new-username中使用“ - ”。使用下划线...