Tema: Validar hora
Ver Mensaje Individual
  #1 (permalink)  
Antiguo 17/10/2011, 13:04
sebacomas
 
Fecha de Ingreso: mayo-2010
Mensajes: 414
Antigüedad: 14 años
Puntos: 2
Validar hora

Hola, estoy validando una entrada para que sea de tipo hora.

el codigo es el suiguiente:


<script>
function horaValida(){
var hora = document.getElementById("posicion").value;
return hora.match("([01]?[0-9]|2[0-3]):[0-5][0-9]");
}

function validarFormulario(formulario){

if(horaValida(true)){
formulario.Upload();
} else {
alert('Hora inválida. Debe ingresarla con el formato 00:00');
return false;
}
}
</script>

el formulario:

<form action='../_php/proceso-editar-hora-entrada.php' onSubmit='return validarFormulario(this)' method='post'>

<input id='posicion' type='text' name='hora' />
<input type='submit' value='Editar' />
</form>

Algo debo estar haciendo mal porque me hace el submit pero no me valida.

Cualquier aporte sirve.
Saludo!