0

我已将我的代码上传到 js bin 并收到以下错误我不确定如何修复它们,但我认为这是由于我试图用来},传递我的 id 值。

Line 7: required: true; --- Expected '}' to match '{' from line 6 and instead saw ';'.
Line 10: required: true; --- Expected '}' to match '{' from line 9 and instead saw ';'.
Line 12: }, --- Expected an identifier and instead saw '}'.
Line 13: errorPlacement: function(error, element) { --- Expected ')' and instead saw ':'.
Line 13: errorPlacement: function(error, element) { --- Missing semicolon.
Line 13: errorPlacement: function(error, element) { --- Missing name in function declaration.
Line 21: }); --- Expected '(end)' and instead saw '}'.

jQuery(document).ready(function() { 
    //Home Validation
    $("#quote").validate({
        onfocusout:true,
          rules:{
                companyName:{
                    required: true;
                },
                companyAddress:{
                    required: true;
                },
            },
            errorPlacement: function(error, element) {
                if(element.is("textarea")) {
                    error.appendTo(".textareaError");
                }else{
                    error.appendTo(".error");
                }
            }
    });
});
4

1 回答 1

1

我删除了第 7 行和第 10 行的分号以及第 11 行的逗号。

jQuery(document).ready(function() { 
    //Home Validation
    $("#quote").validate({
        onfocusout:true,
          rules:{
                companyName:{
                    required: true
                },
                companyAddress:{
                    required: true
                }
            },
            errorPlacement: function(error, element) {
                if(element.is("textarea")) {
                    error.appendTo(".textareaError");
                }else{
                    error.appendTo(".error");
                }
            }
    });
});
于 2012-04-20T03:49:50.597 回答