Full version: jsB@nk » Form » Tab Key Emulation
URL: https://www.javascriptbank.com/tab-key-emulation.html
The tab key is no longer required to tab between fields. The user can go to the next form field just by pressing the enter key instead of the tab key. Useful with 10-key form input. What a time saver!
Full version: jsB@nk » Form » Tab Key Emulation
URL: https://www.javascriptbank.com/tab-key-emulation.html
<SCRIPT LANGUAGE="JavaScript">// Ronnie T. Moore<!-- Beginnextfield = "box1"; // name of first box on pagenetscape = "";ver = navigator.appVersion; len = ver.length;for(iln = 0; iln < len; iln++) if (ver.charAt(iln) == "(") break;netscape = (ver.charAt(iln+1).toUpperCase() != "C");function keyDown(DnEvents) { // handles keypress// determines whether Netscape or Internet Explorerk = (netscape) ? DnEvents.which : window.event.keyCode;if (k == 13) { // enter key pressedif (nextfield == 'done') return true; // submit, we finished all fieldselse { // we're not done yet, send focus to next boxeval('document.yourform.' + nextfield + '.focus()');return false; } }}document.onkeydown = keyDown; // work together to analyze keystrokesif (netscape) document.captureEvents(Event.KEYDOWN|Event.KEYUP);// End --></script><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->
<form name=yourform>Box 1: <input type=text name=box1 onFocus="nextfield ='box2';"><br>Box 2: <input type=text name=box2 onFocus="nextfield ='box3';"><br>Box 3: <input type=text name=box3 onFocus="nextfield ='box4';"><br>Box 4: <input type=text name=box4 onFocus="nextfield ='done';"><br><input type=submit name=done value="Submit"></form><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->