Código:
<SCRIPT TYPE="text/javascript"> <!-- var downStrokeField; function autojump(fieldName,nextFieldName,fakeMaxLength) { var myForm=document.forms[document.forms.length - 1]; var myField=myForm.elements[fieldName]; myField.nextField=myForm.elements[nextFieldName]; if (myField.maxLength == null) myField.maxLength=fakeMaxLength; myField.onkeydown=autojump_keyDown; myField.onkeyup=autojump_keyUp; } function autojump_keyDown() { this.beforeLength=this.value.length; downStrokeField=this; } function autojump_keyUp() { if ( (this == downStrokeField) && (this.value.length > this.beforeLength) && (this.value.length >= this.maxLength) ) this.nextField.focus(); downStrokeField=null; } //--> </SCRIPT>
luego
Código:
<SCRIPT TYPE="text/javascript"> <!-- autojump('a', 'b', 3); autojump('b', 'c', 2); autojump('c', 'd', 4); //--> </SCRIPT>
y los campos
Código:
<input name="a" type="text" id="a" value="" size="18" maxlength="3" /> <input name="b" type="text" id="b" value="" size="18" maxlength="2" /> <input name="c" type="text" id="c" value="" size="18" maxlength="4" />