[問題] jQuery檢查帳號是否存在
<input type="text" id="account" maxlength="10"
onblur="checkAccountExist(this.value);" />
function checkAccountExist(account) {
$.post("checkAccount.action",
{"member.account" : account},
function(data, status){
if ($("accountExist", data).text() == "true"){
alert("您輸入的帳號"+account+"已被其他使用者註冊, 請使用其它帳號");
$("#account").focus();
}
}, "xml");
}
我在註冊時,在輸入帳號的欄位用 onblur
然後用jQuery的$.post()做檢查帳號是否已存在的動作
回傳一 xml如果值為true,則提示使用者,並將游標focus至帳號欄
現在遇到一個問題是,如果用 alt + tab 換到別的視窗再切換回來
有時候會一直出現 alert(),變成一直執行 checkAccount()
請問alert()不是在focus()之前執行嗎,在執行focus()後
還有什麼事件會觸發 onblur 嗎?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 219.87.64.100
→
07/27 12:32, , 1F
07/27 12:32, 1F
→
07/27 12:37, , 2F
07/27 12:37, 2F
→
07/27 12:38, , 3F
07/27 12:38, 3F
推
07/27 13:14, , 4F
07/27 13:14, 4F
→
07/27 13:15, , 5F
07/27 13:15, 5F
→
07/27 13:20, , 6F
07/27 13:20, 6F
Ajax 近期熱門文章
PTT數位生活區 即時熱門文章