自动将光标从一个文本框移动到另一个文本框 [英] Automatically Move Cursor from One Textbox to Another

查看:218
本文介绍了自动将光标从一个文本框移动到另一个文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作验证密码的Web应用程序,并显示一些值,输入的文件有四个密码验证密码,我输入密码,就像我们在支付网关中输入信用卡号一样。在我目前的应用程序中,我输入了一个密码,然后按Tab或使用鼠标我必须选择下一个文本框输入下一个密码,如何使鼠标光标自动从一个文本框跳转到另一个文本框,在其最大值填充像支付网关

I am making a Web application that validates passkeys and displays some values there are four passkeys for a file to be entered Validate it, I am entering the passkeys just like we enter the Credit Card Number in the Payment gateway. In my present application I have enter one Passkey then have to press Tab or using the Mouse I have to select the Next Textbox to enter next Passkey, How do I Make the mouse Cursor to Jump automatically from one Textbox to Another Textbox after its maximum value filled like in Payment gateways

推荐答案

您可以像这样做纯JavaScript:

You can do pure javascript like this:

<script type="text/javascript">
function ValidatePassKey(tb) {
  if (tb.TextLength >= 4)
    document.getElementById(tb.id + 1).focus();
  }
}
</script>

<input id="1" type="text" onchange="ValidatePassKey(this)" maxlength="4">
<input id="2" type="text" onchange="ValidatePassKey(this)" maxlength="4">
<input id="3" type="text" onchange="ValidatePassKey(this)" maxlength="4">
<input id="4" type="text" maxlength="4">

这篇关于自动将光标从一个文本框移动到另一个文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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