我已经阅读了所有文档和网页,并且一旦有效就无法理解如何提交表单。我在我的表格中使用帖子(这有关系吗?)。我的submitHandler中的警报未触发。
//Contact Form Section
$("#formContact").validate({
errorLabelContainer: $("#formContact div.formerror"),
rules: {
Name: "required",
Email: {
required: true,
email: true
},
Message: "required" //minlength: 2
},
messages: {
Name: "Please enter your name (at least 3 letters)",
Email: {
required: "We need your email address to contact you",
email: "Your email address must be in the format of name@domain.com"
},
Message: "Please tell us how we may help you..."
}
submitHandler: function(form) {
alert("Form submitted!"); //form.submit();
}
});
答案 0 :(得分:1)
我想你错过了一个逗号
//Contact Form Section
$("#formContact").validate({
errorLabelContainer: $("#formContact div.formerror"),
rules: {
Name: "required",
Email: {
required: true,
email: true
},
Message: "required" //minlength: 2
},
messages: {
Name: "Please enter your name (at least 3 letters)",
Email: {
required: "We need your email address to contact you",
email: "Your email address must be in the format of name@domain.com"
},
Message: "Please tell us how we may help you..."
},
submitHandler: function(form) {
alert("Form submitted!"); //form.submit();
}
});
可能有效
答案 1 :(得分:0)
因为语法错误。添加逗号并尝试代码。
$("#formContact").validate({
errorLabelContainer: $("#formContact div.formerror"),
rules: {
Name: "required",
Email: {
required: true,
email: true
},
Message: "required" //minlength: 2
},
messages: {
Name: "Please enter your name (at least 3 letters)",
Email: {
required: "We need your email address to contact you",
email: "Your email address must be in the format of name@domain.com"
},
Message: "Please tell us how we may help you..."
},
submitHandler: function(form) {
alert("Form submitted!"); //form.submit();
}
});