Ver Mensaje Individual
  #2 (permalink)  
Antiguo 17/05/2012, 05:27
Avatar de IsaBelM
IsaBelM
Colaborador
 
Fecha de Ingreso: junio-2008
Mensajes: 5.032
Antigüedad: 15 años, 10 meses
Puntos: 1012
Respuesta: Código Autotabulación

buen intento

es verdad que no tiene errores de sintaxis, pero .....
  • a cada pulsación se recorre el ciclo
  • al usar el evento onkeyup y no paserle a la función el objeto event, no puedes hacer un backspace
Cita:
<html>
<head>
<script>


function autoTab(obj, tam)
{
var frm=obj.form;
var largo = obj.value.length;
if (largo == tam) {
for(i=0;i<frm.elements.length;i++) {
if(frm.elements[i]==obj) {
frm.elements[i+1].focus();
break;
}
}
}
}

</script>




</head>

<body>
<form name="formulario">
<input type="text" name="nt1" size="5" maxlength="4" onkeypress="autoTab(this, this.maxLength)" />&nbsp;&nbsp;

<input type="text" name="nt2" size="5" maxlength="4" onkeypress="autoTab(this, this.maxLength)" />&nbsp;&nbsp;

<input type="text" name="nt3" size="5" maxlength="4" onkeypress="autoTab(this, this.maxLength)" />&nbsp;&nbsp;

<input type="text" name="nt4" size="5" maxlength="4" />
</form>
</body>
</html>
__________________
if(ViolenciaDeGénero) {alert('MUJER ASESINADA');}

Última edición por IsaBelM; 17/05/2012 a las 05:50