Código:
function valDia(oTxt){
var bOk = false;
var nDia = parseInt(oTxt.value.substr(0, 2), 10);
bOk = bOk || ((nDia >= 1) && (nDia <= finMes(oTxt)));
return bOk;
}
function valMes(oTxt){
var bOk = false;
var nMes = parseInt(oTxt.value.substr(3, 2), 10);
var nAno = oTxt.value.substr(6);
bOk = bOk || ((nMes >= 1) && (nMes <= 12));
if (nAno == 2002 & nMes <6){ bOk=false}
return bOk;
}
function valAno(oTxt){
var bOk = true;
var nAno = oTxt.value.substr(6);
bOk = bOk && ((nAno.length == 2) || (nAno.length == 4));
if (bOk){
for (var i = 0; i < nAno.length; i++){
bOk = bOk && esDigito(nAno.charAt(i));
}
}
if (nAno < 2002){ bOk = false;}
return bOk;
}
function valFecha(oTxt){
var bOk = true;
if (oTxt.value != ""){
bOk = bOk && (valAno(oTxt));
bOk = bOk && (valMes(oTxt));
bOk = bOk && (valDia(oTxt));
bOk = bOk && (valSep(oTxt));
if (!bOk){
alert("Fecha inválida");
oTxt.value = "";
oTxt.focus();
}
}
}
</script>
</head>
<body>
<form name="f1" onSubmit="return checkForm(this);">
<p> Tarjeta de credito: <input type=text name="tarjeta" size=16 maxlength=16 onKeyPress="return acceptNum(event)"></p>
<p> Fecha (dd/mm/aaaa): <input type="text" size="10" maxlength="10" name="fec" onblur="valFecha(this)"></p>
<p> Nombre: <input type="text" size="10" name="nombre"></p>
<p> Apellido: <input type="text" size="10" name="apellido"></p>
<p> Email: <input type="text" size="10" name="email"></p>
<p> <input type="submit" size="10" value="E N V I A R"></p>
</form>
</body>
</html>
<hr noshade size=1><img src="http://www.gograph.com/Images-8712/ClipArt/cat03.gif" height="50" border=0 align="absmiddle"> <font size="2" face="verdana" color="#000000">
bet[/CODE]