在表单字段中自动前进 [英] Auto-advance in form fields
本文介绍了在表单字段中自动前进的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个简单的脚本,可以在输入一个字符后将光标自动前进到html表单中的下一个字段...因此非常有用.这是简单的代码:
I have a simple script that auto-advances the cursor to the next field in my html form after one character is entered...and it works great for that. This is the simple code:
function autotab(current,to)
{
if (current.getAttribute && current.value.length==current.getAttribute("maxlength"))
{
to.focus()
}
}
然后我当然使用onkeyup来推进它,就像这样:
Then of course I use the onkeyup to advance it, like this:
<input onkeyup="autotab(this, document.jumble.w1b)" type="text">
同样,效果很好.但是,当我执行Shift + Tab键返回一个框时,它会在输入任何内容之前自动前进.
Again, that works great. However, when I do Shift+Tab to go one box back, it auto-advances before I can type anything.
有人有一个代码示例,说明如何使Shift + Tab起作用吗?我尝试过尝试使用键码来检测班次和制表符的不同方法,但它似乎不起作用.
Does anyone have a code example of how to make Shift+Tab work? I have tried different variations of trying to use the keycodes to detect shift and tab, but it doesn't seem to work.
任何帮助将不胜感激!
推荐答案
查看全文