用ASP怎么让文本框的光标写一个数字就自动跳转到下一个,急急!!

来源:百度知道 编辑:UC知道 时间:2024/05/24 11:50:23
Response.Write "<script>var i,t='';for(i=0;i<18;i++)t+=""<input type='text' id='sfhm1' size=1 maxlength=1 style='text-align:center'>"";;tdsfz1.innerHTML=t;" & vbcrlf _

<html>
<head>
<script type="text/javascript">
function checkLen(x,y)
{
if (y.length==x.maxLength)
{
var next=x.tabIndex
if (next<document.getElementById("myForm").length)
{
document.getElementById("myForm").elements[next].focus()
}
}
}
</script>
</head>

<body>
<p>这段脚本在达到文本框的最大长度时跳到下一个文本框:</p>

<form id="myForm">
<input size="3" tabindex="1" maxlength="3" onkeyup="checkLen(this,this.value)">
<input size="2" tabindex="2" maxlength="2" onkeyup="checkLen(this,this.value)">
<input size="3" tabindex="3" maxlength="3" onkeyup="checkLen(this,this.value)">
</form>
</body>

</html>