当前位置:Gxlcms > asp.net > ASP.NET实现License Key输入功能的小例子

ASP.NET实现License Key输入功能的小例子

时间:2021-07-01 10:21:17 帮助过:11人阅读

 

这个演示,在输入时,是不需要与服务端交互,只有全部输入完毕之后,用户点铵钮才进行验证。因此在这里,写Javascript来实现即可。

js:

代码如下:

<script type="text/javascript">
        function JumpToNextTextBox(currentTxtBox, nextTextBoxID) {
            if (currentTxtBox.value.length >= 5) {
                document.getElementById(nextTextBoxID).focus();
            }
        }
    </script>


Html code:

代码如下:

  License Key:
            <asp:TextBox ID="Number1" runat="server" onkeyup="JumpToNextTextBox(this, 'Number2')" Width="65"></asp:TextBox>
            -
        <asp:TextBox ID="Number2" runat="server" onkeyup="JumpToNextTextBox(this, 'Number3')" Width="65"></asp:TextBox>
            -
        <asp:TextBox ID="Number3" runat="server" onkeyup="JumpToNextTextBox(this, 'Number4')" Width="65"></asp:TextBox>
            -
        <asp:TextBox ID="Number4" runat="server" onkeyup="JumpToNextTextBox(this, 'Number5')" Width="65"></asp:TextBox>
            -
        <asp:TextBox ID="Number5" runat="server" MaxLength ="5" Width="65"></asp:TextBox>

人气教程排行