A cópia do código é a seguinte:
<html>
<head>
<script type = "text/javascript">
função movenext (objeto, index) {
if (object.value.length == 4) {
document.forms [0] .Elements [índice+1] .focus ();
}
}
função showResult () {
var f = document.forms [0];
var resultado = "";
for (var i = 0; i <4; i ++) {
resultado+= f.Elements [i] .Value;
}
alerta (resultado);
}
</script>
</head>
<corpo onload = "document.forms [0] .elements [0] .focus ();">
<morm>
<input type = "text" size = "3" maxlength = "4" onkeyup = "movenext (this, 0);">
<input type = "text" size = "3" maxlength = "4" onkeyup = "moveNeNext (this, 1);">
<input type = "text" size = "3" maxLength = "4" onkeyup = "movenext (this, 2);">
<input type = "text" size = "3" maxlength = "4" onkeyup = "moveNeNext (this, 3);">
<input type = "button" value = "show" onclick = "showResult ();">
</morm>
</body>
</html>
O código é muito simples e as funções são muito práticas. Os amigos podem usá -lo em seu próprio projeto após o embelezamento. Não é legal?