Ver Mensaje Individual
  #2 (permalink)  
Antiguo 10/03/2007, 12:45
Avatar de JavierB
JavierB
Colaborador
 
Fecha de Ingreso: febrero-2002
Ubicación: Madrid
Mensajes: 25.052
Antigüedad: 23 años
Puntos: 772
Re: Restar fechas desde un type="text"

Hola helthon

A ver si te he entendido bien. Pon así el campo de texto:

<input type="text" onblur="validar(this)" />

y usa este código:

Código PHP:
function validar(obj) {
  
hoy = new Date();
  
fecha = new Date(obj.value);
  
hoy.setTime(hoy.getTime()-2*24*60*60*1000); // restamos 2 días
  
if (fecha hoy) {
    
alert('error');
    
obj.focus();
  }

Las fechas tienes que estar en formato yyyy/mm/dd

Saludos,