<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>JavaScript to automatically move from one field to another field</title> <script type="text/javascript"> function movetoNext(current, nextFieldID) { if (current.value.length >= current.maxLength) { document.getElementById(nextFieldID).focus(); } } </script> </head> <body> Enter your Text: <input type="text" id="first" size="4" onkeyup="movetoNext(this, 'second')" maxlength="3" /> <input type="text" id="second" size="4" onkeyup="movetoNext(this, 'third')" maxlength="3" /> <input type="text" id="third" size="5" maxlength="4" /> </body> </html>
document.getElementById('txt1').onkeydown = function() { if (this.value.length == this.maxLength) document.getElementById('txt2').focus(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)