关于 输入框输入一定数以后跳转的问题

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
function maxleng(objec,index){
   if(objec.value.length==4){
       document.forms[0].elements[index+1].focus();//每次到四个了选择下一个输入框
       }
    }
</script>
</head>

<body onload="document.forms[0].elements[0].focus()" >
<form>
<input type="text" maxlength="4" onkeyup="maxleng(this,0)" />-
<input type="text" maxlength="4" onkeyup="maxleng(this,1)" />-
<input type="text" maxlength="4" onkeyup="maxleng(this,2)" />-
<input type="text" maxlength="4" onkeyup="maxleng(this,3)" />-
<input type="button" value="提交" />
</form>
</body>
</html>

原文地址:https://www.cnblogs.com/baikaishui/p/2339683.html