我已将我的代码上传到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");
}
}
});
});
答案 0 :(得分: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");
}
}
});
});