欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

让焦点自动跳转

程序员文章站 2022-07-11 18:38:57
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<title>html-www.51windows.net</title>
</head>
<body>
以下四个文本框,每个限输入四个字符,输入完后自动跳到下一文本框
<script id="clienteventhandlersjs" 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();
}
}

function t3_onkeyup() {
if(document.card.t3.value.length==4){
document.card.t4.focus();
}
}
//-->
</script>
<form method="post" name="card" action>
输入字符:
<input type="text" name="t1" size="4" maxlength="4" language="javascript" onkeyup="return t1_onkeyup()">-

<input type="text" name="t2" size="4" maxlength="4" language="javascript" onkeyup="return t2_onkeyup()">-

<input type="text" name="t3" size="4" maxlength="4" language="javascript" onkeyup="return t3_onkeyup()">-

<input type="text" name="t4" size="4" maxlength="4">
</form>
</body>
</html>

<div style="position: absolute; top: 10; right: 10; width: 148; height: 18;cursor:hand">
<input type="button" name="button" value="查看源代码" onclick= 'window.location = "view-source:" + window.location.href'></div>