服务器之家:专注于服务器技术及软件下载分享
分类导航

PHP教程|ASP.NET教程|JAVA教程|ASP教程|

服务器之家 - 编程语言 - ASP.NET教程 - ASP.NET实现License Key输入功能的小例子

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

2019-10-28 13:10asp.net技术网 ASP.NET教程

当我们安装微软的软件,多数软件是需要输入license key。它有五个文本框,输入完第一个文本框之后,光标自动跳至下一个文本框。 Insus.NET今天也使用asp.net来模仿一个。呵呵。

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

 

这个演示,在输入时,是不需要与服务端交互,只有全部输入完毕之后,用户点铵钮才进行验证。因此在这里,写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>

 

延伸 · 阅读

精彩推荐