为什么这段代码不起作用的任何想法?
var newpost_validator = {};
var editpost_validator = {};
var newupload_validator = {};
var editupload_validator = {};
var newquestion_validator = {};
var editquestion_validator = {};
var comment_validator = {};
$(function()
{
newpost_validator = $("#newpostform").validate({
rules: {
post_title: "required",
post_url: {
required: {
depends: function() {
return $('input[name=post_category]:checked').val() == '14';
}
},
url: true
},
post_code: {
required: {
depends: function() {
return $('input[name=post_category]:checked').val() == '13';
}
}
},
post_content: "required",
post_tags: "required"
},
messages: {
post_title: "Your post MUST have a title",
post_url: "Please enter a valid URL, don't forget the http://",
post_code: "Please add your code",
post_content: "Your post MUST have some content",
post_tags: "Please add some tags"
}
});
editpost_validator = $("#editpostform").validate({
rules: {
post_title: "required",
post_content: "required"
},
messages: {
post_title: "Please enter a title",
post_content: "Please enter the content"
}
});
newquestion_validator = $("#newquestionform").validate({
rules: {
post_title: "required",
post_content: "required",
post_tags: "required"
},
messages: {
post_title: "Please enter a title",
post_content: "Please enter the content",
post_tags: "Please enter some tags"
}
});
editquestion_validator = $("#editquestionform").validate({
rules: {
post_title: "required",
post_content: "required"
}, },
messages: {
post_title: "Please enter a title",
post_content: "Please enter the content"
}
});
newupload_validator = $("#newuploadform").validate({
rules: {
post_title: "required",
post_upload: {
required: true,
accept: "jpg|jpeg|gif|bmp|png"
},
post_content: "required",
post_tags: "required"
},
messages: {
post_title: "Please enter a title",
post_upload: "Please upload a valid image file",
post_content: "Please enter the content",
post_tags: "Please enter some tags"
}
});
editupload_validator = $("#edituploadform").validate({
rules: {
post_title: "required",
post_content: "required"
},
messages: {
post_title: "Please enter a title",
post_content: "Please enter the content"
}
});
comment_validator = $("#commentform").validate({
rules: {
comment: "required"
},
messages: {
comment: "Please add a comment"
}
});
});
由于没有任何表格得到验证:/
感谢。
答案 0 :(得分:0)
发现错误:)似乎我已经完成了这个}, },