0
我使用localstoragedb爲我的本地數據庫,直到現在無論我所做的工作是正確的。但是在提交表單時返回false並不會停止提交表單。 下面是代碼.....返回false不工作在localstoragedb
$("#registration").on("submit", function(e) {
e.preventDefault();
if ($('#username').val() === '') {
$('#username').parent().addClass('error');
return false;
};
if ($('#password').val() === '') {
$('#password').parent().addClass('error');
return false;
};
if ($('#mobile').val() === '') {
$('#mobile').parent().addClass('error');
return false;
};
localDb.queryAll("UserInfo");
localDb.queryAll("UserInfo", {
query: function(row) {
if (row.username === $('#username').val()) {
alert("username already existed");
return false;
}
}
});
localDb.insert("UserInfo", {
username: $('#username').val(),
password: $('#password').val(),
Mobile: $("#mobile").val()
});
localDb.commit();
$(".message").show();
setTimeout(function() {
window.location.replace("login.html");
}, 2000);
});
全部返回假工作正常,除了內localDb.queryAll
功能。 它會提醒我用戶名已存在但也提交了表格。 看起來像return false
有些問題。 是我失蹤或做錯了嗎? 在此先感謝.........