运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,暗色/亮色
前往 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>