3

Firefox 不断给我这个消息:

 Hour: 16:11:32
 Erro: SyntaxError: missing } after property list
 Line: 12, Column: 2

 Messages: { name: { required: "Your name here", minlength:

这是代码:

$(document).ready(function() {
    $("a").click(function() {
        alert("Hello evrbdy");
    });

    $("#button1").click(function() {
        $("a").hide("slow");
    });
    $("#fomu").validate({
        rules: {
            nome: {
                required: true,
                minlength: 6
            }
        }
        messages: {
            nome: {
                required: "some message",
                minlength: "some other message"
            }
        }
    });
});​

我究竟做错了什么?

4

2 回答 2

18
rules:{ 
    nome:{
        required: true, 
        minlength: 6
    } 
},
messages:{  
    nome:{  
        required: "some message",   
        minlength: "some other message"
    }   

规则数据对象后缺少逗号

于 2012-10-24T18:20:50.410 回答
6

通过美化器运行代码以修复间距,这样会更容易发现:

$(document).ready(function () {
    $("a").click(function () {
        alert("Hello evrbdy");
    });

    $("#button1").click(function () {
        $("a").hide("slow");
    });
    $("#fomu").validate({
        rules: {
            nome: {
                required: true,
                minlength: 6
            }
        }, // <-- missing comma here
        messages: {
            nome: {
                required: "some message",
                minlength: "some other message"
            }
        }
    });
});
于 2012-10-24T18:22:38.040 回答