<input id=edit1 maxlength=5 onkeyup=if(this.value.length==5)edit2.focus()>
<input id=edit2 maxlength=5 onkeyup=if(this.value.length==5)edit3.focus()>
...

解决方案 »

  1.   

    try:<HTML>
    <HEAD>
    <Script Language="JavaScript">
    function nextInput(obj)
    {
      var i = obj.sourceIndex;
      while (i < document.all.length)
      {
    ++i;
    if (document.all[i] && document.all[i].tagName == "INPUT" && document.all[i].type=="text")
    break;
      }  if (i == document.all.length)
    return null;
      else
    return document.all[i];
    }function checkInput(obj) {
     
     if (obj.value.length >=5) 
     {
      var input = nextInput(obj);
      if (!input)
      {
    window.event.returnValue = false;
      }
      else
      {
    input.focus();
    checkInput(input);
      }
     }
    }
    </Script>
    </HEAD>
    <BODY>
    <input type="text" name="text1" onkeypress="checkInput(this);">
    <input type="text" name="text2" onkeypress="checkInput(this);">
    <input type="text" name="text3" onkeypress="checkInput(this);">
    <input type="text" name="text4" onkeypress="checkInput(this);">
    <div>test<div>
    </BODY>
    </HTML>