预期的逗号,但发现缩进/预期的eof但找到了}

时间:2017-04-21 15:30:05

标签: javascript

在这个js中有两个错误,并且在我的生活中无法想象它们。总新手,对不起......已经通过好几个答案和文章拖网无济于事。

错误在第50和第53行(为方便起见而标记)

第一个问题,很好......

    $(function() {
    // Initialize form validation on the registration form.
    // It has the name attribute "registration"
    $("form[name='registration']").validate({

    errorElement: 'div',
            rules: {
            first_name: "required",
            last_name: "required",
            email: {
            required: true,
                    validEmail: true
            },
            university: {
            required: true,
                    minlength: 2
            },
            pass_one: {
            required: true,
                    minlength: 5
            },
            pass_two: {
            required: true,
                    minlength: 5,
                    equalTo: "#password"
            },
    },
    messages: {
    first_name: "Please enter your firstname",
            last_name: "Please enter your lastname",
            university: {
            required: "Please enter your university",
                    minlength: "Must be at least 2 charachters"
            },
            pass_one: {
            required: "Please provide a password",
                    minlength: "Password must be at least 5 charachters 
    long"
            },
            pass_two: {
            required: "Please re-enter password",
                    minlength: "Must be 5 charchters long",
                    equalTo: "passwords do not match poo face"
            }

    },
    submitHandler: function(form) {
    form.submit();
    }

    /*50*/        JQuery.validator.addMethod("validEmail", function(value, element) {
               return this.optional(element) || /^.+@ul.ie$/.test(value);
            }, "Only UL email addresses are allowed.");
    /*53*/  });

    });

1 个答案:

答案 0 :(得分:0)

这一行:

required: "Please provide a password",
                minlength: "Password must be at least 5 charachters 
long"

有一个换行符。这不是JS中多线字符串的工作方式。

这些行:

JQuery.validator.addMethod("validEmail", function(value, element) { //etc

应该住在其他地方,而不是validate对象参数。