叫我使用JQuery驗證來自:http://bassistance.de/jquery-plugins/jquery-plugin-validation/JQuery的驗證 - 成功函數在未能有效提交
我已經寫了JQuery的,我需要這驗證正確但是我提交功能的最後一部分不能正常工作。
$("#commentForm").validate({
rules: {
email_options_name: {
required: true
},
email_options_company: {
required: true
},
email_options_country: {
required: true
},
email_option_email: {
required: true,
email: true
},
check_options: {
required: true,
minlength: 1
}
},
});
$("#commentForm").submit(function(){
var valid = $("#commentForm").valid();
if (valid) {
$.post('scripts/process_email_initial_form.php',$(this).serialize(), function(o) {
location.reload();
}, 'json');
} else {
$('.full-error').show();
}
return false;
});
$.extend($.validator.messages, {
required: "!",
email: "!"
});
}
當提交有效腳本process_email_initial_form.php
被調用,並正確處理(從尋找到螢火蟲),如果不股利不顯示。問題是當腳本運行完成時location.reload();
沒有調用。理想情況下,我想直接進入成功頁面,但這也不起作用。
我試圖在process_email_initial_form.php
的末尾放置一個php頭函數,但這也不起作用。
任何幫助,非常感謝。
[閱讀文檔](http://docs.jquery.com/Plugins/Validation/validate#toptions)。 **使用'submitHandler'回調函數。**這是你放置'ajax'的地方。您的外部'submit'處理程序正在搞砸插件的內置提交處理程序。 – Sparky