La copie de code est la suivante:
<html>
<adal>
<script type = "text / javascript">
fonction movnext (objet, index) {
if (object.value.length == 4) {
document.forms [0] .Elements [index + 1] .focus ();
}
}
fonction showResult () {
var f = document.forms [0];
var result = "";
pour (var i = 0; i <4; i ++) {
Résultat + = F.Elements [i] .Value;
}
alerte (résultat);
}
</cript>
</ head>
<body onload = "document.forms [0] .Elements [0] .focus ();">
<formulaire
<input type = "text" size = "3" maxLength = "4" onkeyup = "movnext (this, 0);">
<input type = "text" size = "3" maxLength = "4" onkeyup = "movnext (this, 1);">
<input type = "text" size = "3" maxLength = "4" onkeyup = "movnext (this, 2);">
<input type = "text" size = "3" maxLength = "4" onkeyup = "movnext (this, 3);">
<input type = "bouton" value = "show" onclick = "showResult ();">
</ form>
</docy>
</html>
Le code est très simple et les fonctions sont très pratiques. Les amis peuvent l'utiliser dans leur propre projet après l'embellissement. N'est-ce pas cool?