在我的index.php页面上,表单动作属性为'target.php'。我使用jQuery Valdiate来验证表单。jQuery验证在指定div中提交
<form action="target.php" method="post" class="contact-validate">
<div>
<div id="sent"></div>
<input type="text" placeholder="Przedstaw się" name="name" id="name" />
<input type="text" placeholder="Miejscowość" name="city" id="city" />
<button type="submit" id="submit">Send form *</button>
</div>
</form>
问题是,经过正确的验证,操作表单是作为其他页面执行的,但是我需要这个操作可以在#sent div中执行。
这里jQuery代码
<script>
jQuery('.contact-validate').validate({
rules: {
"name": {
required: true
},
"city": {
required: true
}
},
submitHandler: function(form) {
form.submit();
}
});
</script>
我不知道我需要在“submitHandler”
...要添加Ajax表单提交。 – Regent
看到http://api.jquery.com/event.preventdefault/ –
所以jquery验证没有自己的能力做到这一点?我需要使用ajax? – X9DESIGN