<!DOCTYPE html>
<html>
<head>
</head>
<body>
<form>
<input type="text" id="input1" onkeyup="saltar(event,'input2')">
<br><input type="text" id="input2" onkeyup="saltar(event,'input3')">
<br><input type="text" id="input3" onkeyup="saltar(event,'input4')">
<br><input type="text" id="input4" onkeyup="saltar(event,'submit')">
</form>
</body>
</html>
<script>
// Funcion que se ejecuta cada vez que se pulsa una tecla en cualquier input
// Tiene que recibir el "event" (evento generado) y el siguiente id donde poner
// el foco. Si ese id es "submit" se envia el formulario
function saltar(e,id)
{
// Obtenemos la tecla pulsada
(e.keyCode)?k=e.keyCode:k=e.which;
// Si la tecla pulsada es enter (codigo ascii 13)
if(k==13)
{
// Si la variable id contiene "submit" enviamos el formulario
if(id=="submit")
{
document.forms[0].submit();
}else{
// nos posicionamos en el siguiente input
document.getElementById(id).focus();
}
}
}
</script>
Comentarios sobre la versión: Versión 1.0 (6)
Gracias por el aporte.
Un saludo