Copy Code code as follows:
<script type= "Text/javascript" >
function MoveNext (object,index) {
if (object.value.length==4) {
Document.forms[0].elements[index+1].focus ();
}
}
function Showresult () {
var f=document.forms[0];
var result= "";
for (Var i=0;i<4;i++) {
Result+=f.elements[i].value;
}
alert (result);
}
</script>
<body onload= "Document.forms[0].elements[0].focus ();" >
<form>
<input type= "Text" size= "3" maxlength= "4" onkeyup= "MoveNext (this,0);" >
<input type= "Text" size= "3" maxlength= "4" onkeyup= "MoveNext (this,1);" >
<input type= "Text" size= "3" maxlength= "4" onkeyup= "MoveNext (this,2);" >
<input type= "Text" size= "3" maxlength= "4" onkeyup= "MoveNext (this,3);" >
<input type= "button" value= "shows" onclick= "Showresult ();" >
</form>
</body>
The code is very simple, the function is very practical, the small partner beautification can use to own project, is not very cool