如何聚焦文本框,文本框位于以下格式? [英] How to focus textbox, Textbox located following format?
本文介绍了如何聚焦文本框,文本框位于以下格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要使用javascript来集中我的文本框控件:
注意:
我的文本框控件位于以下格式中,
如何聚焦我的文本框控件?
I need to focus my textbox control using javascript:
Note:
My text Box Control is located in this following format,
How to focus my Text box control?
<asp:CreateUserWizard ID="CreateUserWizard1">
<WizardSteps>
<asp:CreateUserWizardStep ID="CreateUserWizardStep1" >
<ContentTemplate>
<asp:TextBox ID="UserName"/>
</ContentTemplate>
</asp:CreateUserWizardStep>
</WizardSteps>
</asp:CreateUserWizard>
推荐答案
像这样:
like this:
<script>
var txtBox = document.getElementById("UserName");
if (txtBox != null )
{
txtBox.focus();
}
</script>
<script>
var txtBox = document.getElementById("UserName");
if (txtBox.value == "")
{
txtBox.focus();
}
</script>
这篇关于如何聚焦文本框,文本框位于以下格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文