jquery validation missing } after property list

瘦欲@ 提交于 2019-12-13 16:26:09

问题


I have this code here:

$("#order").validate({
    rules: {
        name: {
            required: true
        }
        lastname: {
            required: true
        }
        address: {
            required: true
        }
        telephone: {
            required: true
            digits: true
        }
        email: {
            required: true
            email: true
        }
    }
    submitHandler: function (form) {
        debug = true;
        $(form).ajaxSubmit();
        $("#thanks").show(1000);
        $("#datadiv").hide(500);
    }
});

and it throws "missing } after property list" error on firebug on line 4 in this code. And for the love of me, I can't figure out why - because I'm doing everything by jquery documentation.


回答1:


You need to put commas in between properties of an object literal you are defining. For example:

name: { required: true },  // <-- note the comma
lastname: { required: true },
address: { required: true },
//etc


来源:https://stackoverflow.com/questions/4146732/jquery-validation-missing-after-property-list

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!