您好,我需要在完成一些驗證後提交一個頁面。我從來沒有使用jQuery之前,有任何想法如何做到這一點? 腳本來自本教程http://webcloud.se/log/Form-validation-with-jQuery-from-scratch/如何使用jQuery提交頁面
<form method="post" action="/contact-process" id="demo-form">
<script>
var demoForm = $("#demo-form");
demoForm.validation();
demoForm.submit(function (e) {
$("#valid-form").remove();
if (demoForm.validate()) {
demoForm.append("<strong id='valid-form'>Form is valid!</strong>");
// Here submit the page
}
e.preventDefault();
});
</script>
document.name_of_the_form.submit –
如果你想要的網頁,只是正常提交和確認後,頁面刷新,只是把'e.preventDefault() '在'else'後面''在'if'後面''。 – Orbling
是否帶有「valid-form」標識的元素,「