Without further ado, the key code is as follows:
---Restoring content start---<html> <head> <script>window.onload=function(){ var form=document.getElementsByTagName('form')[0]; var txt=form.elements['txt1']; var txt1=form.elements['txt2']; txt.onkeyup=function(){ if(this.value.length==this.maxLength){ for(var i=0;i<form.elements.length;i++){ if(form.elements[i]==this){ form.elements[i+1].focus(); } } } } } } } } } } } } } } } } } </script> </head> <body> <form> <input type="text" name="txt1" maxlength="5"> <input type="text" name="txt2" maxlength="4"> </form> </body></html>---Restoring content ends---The above is the JavaScript form focus automatic switching code introduced to you by the editor. I hope it will be helpful to everyone!