Ver Mensaje Individual
  #4 (permalink)  
Antiguo 03/06/2006, 08:32
Avatar de JavierB
JavierB
Colaborador
 
Fecha de Ingreso: febrero-2002
Ubicación: Madrid
Mensajes: 25.052
Antigüedad: 22 años, 3 meses
Puntos: 772
Hola de nuevo.

El problema es que el código coge la fecha de hoy a las 00:00 y si lo están escribiendo 1 minuto después lo toma como una fecha anterior. He hecho algunos retoque, a ver que tal:
Código PHP:
<html>
<
head>
<
script type="text/javascript">
function 
valida(fec) {
  
fec=fec.split('-').join('/');
  
f1=new Date(fec+' 23:59:59');
  
f2=new Date();
  if (
f1<f2) {
    
alert('La fecha no puede ser anterior');
    return 
false;
    }
  
f2.setTime(f2.getTime()+7*24*60*60*1000);
  if (
f1>f2) {
    
alert('Han pasado más de 7 días');
    return 
false;
    } 
}
</script>
</head>
<body>
<form action="javascript:alert('si')" onsubmit="return valida(fecha.value)">
<input type="text" name="fecha" />
<input type="submit" />
</form>
</body>
</html> 
Saludos,