按下Enter时,光标自动跳到下一个文本框
<html>
<head>
</head>
<script language="JavaScript">
document.onkeydown = function()
{
if(event.keyCode == 13)
{
event.keyCode = 9;
}
}
</script >
<body>
<form>
<input type="text" id="first" tabIndex="1">
<input type="text" id="second" tabIndex="2">
</form>
</body>
<html>
或者
<script LANGUAGE="javascript">
function T1_onkeyup() {
if(document.card.T1.value.length==4){
document.card.T2.focus();
}
}
function T2_onkeyup() {
if(document.card.T2.value.length==4){
document.card.T3.focus();
}
}
</script>
<input type="text" name="T1" onkeyup="return T1_onkeyup()">-
<input type="text" name="T2" onkeyup="return T2_onkeyup()">-
<input type="text" name="T3" onkeyup="return T3_onkeyup()">-
本文介绍了一种使用JavaScript实现当用户按下Enter键时,光标能够自动跳转到下一个文本框的方法。通过监听键盘事件和设定特定的tabIndex属性来完成这一功能。

3558

被折叠的 条评论
为什么被折叠?



