Run ❯
Get your
own
website
Result Size:
625 x 565
×
Change Orientation
Save Code
Change Theme, Dark/Light
Go to Spaces
<!DOCTYPE html> <html> <body> <p>This script automatically jumps to the next text field when a field's maxlength has been reached:</p> <form id="myForm"> <input type="text" size="3" tabindex="1" maxlength="3" onkeyup="myFunction(this,this.value)"> - <input type="text" size="2" tabindex="2" maxlength="2" onkeyup="myFunction(this,this.value)"> - <input type="text" size="3" tabindex="3" maxlength="3" onkeyup="myFunction(this,this.value)"> </form> <script> function myFunction(x, y) { if (y.length == x.maxLength) { var next = x.tabIndex; if (next < document.getElementById("myForm").length) { document.getElementById("myForm").elements[next].focus(); } } } </script> </body> </html>