我使用表單驗證這段代碼,的jQuery/JavaScript表單驗證工作不
$("#btnaddregistration").live("click", function(e) {
e.preventDefault();
var errorCount = 0;
$("#formaddregistration").find("input").each(function(i) {
if ($(this).val().length == 0) {
errorfield = $(this);
errorCount++;
$("#modaldialogtext").text("'" + $(this).parent().parent().find("label").text() + "' cannot be left blank.");
$("#modal_confirmation").dialog("open");
return false;
}
});
if (errorCount > 0) {
return false;
} else {
document.forms["formaddregistration"].submit();
}
});
但形式不提交。我使用了所有可能的提交方法,但是我失敗了。任何想法我錯了?
你試過'$( 「#formaddregistration」)。submit()'yet?畢竟你有jQuery可用。 – Sparky
你是否在控制檯部分有任何錯誤 –
雅男人,我試過$(「#formaddregistration」)。 。它表明f [a]不是一個函數。對於這段代碼,我得到的document.form.formaddregistration.submit不是一個函數。即使我有回報的真實;但仍然不適合我。 – Shyantanu