在添加 JQuery 验证之前,我让这段代码工作得很好。现在,就目前而言,验证工作正常,一旦按下提交按钮,我确实收到了电子邮件,但最后两个语句(表单重置和警报)不再触发。我在这里做错了什么?
<script type="text/javascript">
// wait for the DOM to be loaded
$(document).ready(function() {
$('#contact_form').validate({
rules:{
namefield:{
required:true,
minlength: 10
},
emailaddress:{
required:true,
minlength: 12,
email: true
},
textmessage:{
required:true,
minlength: 12,
maxlength: 2500
},
},
errorElement: "div",
wrapper: "div class=\"validatemessage\""
}),
$('#contact_form').ajaxForm(function() {
$('#contact_form')[0].reset();
alert("Thank you for your email!");
});
});
</script>