<asp:TextBox ID="txtForgotUserId" runat="server" ClientIDMode="Static" onblur="CheckUserId()"></asp:TextBox>
<asp:Button ID="btnForgotExit" runat="server" Text="Exit" CssClass="art-button" ClientIDMode="Static" OnClientClick="hidepop()"/>
<script type="text/javascript">
function hidepop() {
$find('MpForgot').hide();
return true;
}
function CheckUserId() {
document.getElementById('btnCheckUserId').click();
}
</script>
答案 0 :(得分:1)
代码正在按预期工作,因为只要TextBox失去焦点就会调用onblur。我建议在不同的地方调用CheckUserId()
- 可能是在点击按钮时 - 而不是TextBox onblur。
如果你必须在onblur期间拨打CheckUserId()
,那么你可以使用这样的计时器:
<asp:TextBox ID="txtForgotUserId" runat="server"
ClientIDMode="Static" onblur="startCheckUserIdTimer()"></asp:TextBox>
<asp:Button ID="btnForgotExit" runat="server" Text="Exit"
CssClass="art-button" ClientIDMode="Static" OnClientClick="hidepop()"/>
<script type="text/javascript">
var timer;
function hidepop() {
clearTimeout(timer);
$find('MpForgot').hide();
}
function startCheckUserIdTimer() {
clearTimeout(timer);
timer = setTimeout("CheckUserId()", 100);
}
function CheckUserId() {
clearTimeout(timer);
document.getElementById('btnCheckUserId').click();
}
</script>