需要单击两次才能激活文本框 [英] Need click twice to active a textbox

查看:130
本文介绍了需要单击两次才能激活文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在aspx页面中,有几个文本框(例如txtBoxA和txtBoxB)。理想情况下,在txtBoxA中输入值后,单击TAB和RETURN键将激活txtBoxB。但是,最初加载页面时,需要单击两次才能激活txtBoxB。如何调试此问题?谢谢。

相关代码如下:

In am aspx page, there are a couple of textbox (e.g. txtBoxA and txtBoxB). Ideally, after entering values in txtBoxA, clicking a TAB and RETURN key will make txtBoxB activated. However, when the page is initially loaded, it needs to click twice to activate txtBoxB. How can this problem be debugged? Thanks.
The related codes are below:

<table>
    <tr>
        <td class="style1">
            <asp:TextBox ID="txtUser" runat="server" Font-Size="Small"  AutoPostBack="true"
                TabIndex="2" onkeydown="onFocus(event);"
                Text =""
                ></asp:TextBox>
        </td>
    </tr>
    <tr>
        <td class="style1">
            <asp:TextBox ID="txtPassword" ClientID="txtPassword" runat="server" Font-Size="Small" AutoPostBack="true"
                TextMode="Password" TabIndex="3" >
            </asp:TextBox>
        </td>

    function onFocus(event) {
        var e1 = document.getElementById('<%=txtUser.ClientID%>').value;
        if (e1.length > 5) {
            if (event.keyCode == 13) {      // RETURN
                event.keyCode = 9;
                return event.keyCode;
            }
        }
    }
    </tr>
</table>

推荐答案

标签会移动关于链接等事情。如果默认的Tab键顺序不适合您,请尝试使用tabindex定义您自己的选项卡



http://www.w3schools.com/tags/att_global_tabindex.asp [ ^ ]
Tab will move on to things like links etc too. If the default tab order isn't working for you, try defining your own using tabindex

http://www.w3schools.com/tags/att_global_tabindex.asp[^]


这篇关于需要单击两次才能激活文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆