<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Documento senza titolo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<SCRIPT LANGUAGE="JavaScript">
function controlloData(inputData) {
if (inputData.value.substring(2,3) != "/" ||
inputData.value.substring(5,6) != "/" ||
isNaN(inputData.value.substring(0,2)) ||
isNaN(inputData.value.substring(3,5)) ||
isNaN(inputData.value.substring(6,10))) {
alert(inputData.name + ": Inserire data in formato gg/mm/aaaa");
if (inputData.name == "CampoData1") {
inputData.value = document.form1.appoggio1.value;
} else if (inputData.name == "CampoData2") {
inputData.value = document.form1.appoggio2.value;
}
return false;
} else if (inputData.value.substring(0,2) > 31) {
alert(inputData.name + ": Impossibile utilizzare un valore superiore a 31 per i giorni");
if (inputData.name == "CampoData1") {
inputData.value = document.form1.appoggio1.value;
} else if (inputData.name == "CampoData2") {
inputData.value = document.form1.appoggio2.value;
}
return false;
} else if (inputData.value.substring(3,5) > 12) {
alert(inputData.name + ": Impossibile utilizzare un valore superiore a 12 per i mesi");
if (inputData.name == "CampoData1") {
inputData.value = document.form1.appoggio1.value;
} else if (inputData.name == "CampoData2") {
inputData.value = document.form1.appoggio2.value;
}
return false;
} else if (inputData.value.substring(6,10) < 1900) {
alert(inputData.name + ": Impossibile utilizzare un valore inferiore a 1900 per l'anno");
if (inputData.name == "CampoData1") {
inputData.value = document.form1.appoggio1.value;
} else if (inputData.name == "CampoData2") {
inputData.value = document.form1.appoggio2.value;
}
return false;
}
document.form1.appoggio.value = "";
}
function copia(inputData) {
if (inputData.name == "CampoData1") {
document.form1.appoggio1.value = inputData.value;
} else if (inputData.name == "CampoData2") {
document.form1.appoggio2.value = inputData.value;
}
}
</script>
</head>
<body>
<form name="form1" method="post" action="">
<table width="300" border="1" align="center">
<tr>
<td width="150">Data 1:</td>
<td width="150">
<input type="text" name="appoggio1" style="display:none;">
<input type="text" name="CampoData1" value="01/01/2001" onBlur="controlloData(this);" onFocus="copia(this);" maxlength="10">
</td>
</tr>
<tr>
<td width="150">Data 2:</td>
<td width="150">
<input type="text" name="appoggio2" style="display:none;">
<input type="text" name="CampoData2" value="02/02/2002" onBlur="controlloData(this);" onFocus="copia(this);" maxlength="10">
</td>
</tr>
</table>
</form>
</body>
</html>