Ver Mensaje Individual
  #2 (permalink)  
Antiguo 26/03/2004, 09:15
Avatar de KarlanKas
KarlanKas
Moderador extraterrestre
 
Fecha de Ingreso: diciembre-2001
Ubicación: Madrid
Mensajes: 6.987
Antigüedad: 23 años, 1 mes
Puntos: 61

Si la fecha tiene este formato: 26/3/2004 o similar podríamos hacer:

Código PHP:
<html>
<
head>
    <
title>Untitled</title>
</
head>

<
body>
<
script>
var 
mal;
hoy=new Date();
fecha=new Array();
dia=new Array;
dia[0]=hoy.getDate();
dia[1]=hoy.getMonth()+1;
dia[2]=hoy.getYear();
nombre=["día","mes","año"];
uniones=" -/+@|."
function comprobar(esto){
separador="";
for(
q=0;q<uniones.length;q++){
fecha=esto.split(uniones.charAt(q));
if(
fecha.length==3){separador=uniones.charAt(q);break;}
}
if(!
separador){alert("No se usó un separador válido.\nSon separadores válidos: "+uniones);}
else{

for(
a=0;a<3;a++){
if(
dia[a]!=parseInt(fecha[a])){alert("fechas distintas. El "+nombre[a]+" no coincide");mal=true}
}
if(!
mal){alert("es la misma fecha!");}
mal=false
}}

</script>

<input type="text" name="fecha" size="10" maxlength="10" onBlur="comprobar(this.value);">
</body>
</html> 
__________________
Cómo escribir

No hay pregunta tonta, sino tonto que quiere seguir en la ignorancia.