Over a million developers have joined DZone.

Auto Tab //JavaScript Function

·

Auto tabulation of text inputs with maxlength setted

Usage: just add the code on the end of your page or call it on the onload event (worse solution) and "the enter tabulation" will be added for all fields enclosed by the 
tag. [UPDATED CODE AND HELP CAN BE FOUND HERE] @REQUIRES Event-Listener //Requires http://www.jsfromhell.com/Geral/event-listener //+ Jonas Raoni Soares Silva //@ http://jsfromhell.com/forms/auto-tab [v1.0] autoTab = function(){ for( var d, f = ( d = document ).forms, i = f.length; i; addEventListener( f[--i], "keyup", function( e ){ var el, k = String.fromCharCode( e.key ), l = ( e = e.target ).value.length; if ( l >= ( e.getAttribute( "maxlength" ) || l + 1 ) && /[\wÀ-ÿ ]/.test( k ) ){ for( l = k = ( el = e.form.elements ).length; el[--k] != e; ); while( !(e = el[ k = ++k * ( k < l ) ]).type || e.disabled ); e.focus(); } } ) ); };
Topics:

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}