// JavaScript Document

function controllaData(valore,campodata) {
	if (valore != "gg/mm/aaaa" && valore != '') {
		//ASSEGNO AD UNA VARIABILE IL CONTENUTO DEL CAMPO TESTO 
		//ESTRAGGO I VALORE RELATIVI A GIORNO,MESE,ANNO
		primacoppia=valore.substr(0,2)
		secondacoppia=valore.substr(3,2)
		quadrupla=valore.substr(6,4)
		//CONVERTO I VALORI STRINGA IN NUMERI
		numero=parseInt(primacoppia)
		numero1=parseInt(secondacoppia)
		numero2=parseInt(quadrupla)
		//estraggo le posizioni relative agli slash
		primoslash=valore.substr(2,1)
		secondoslash=valore.substr(5,1)
		//CALCOLO LA LUNGHEZZA DELLE VARIABILE CHE CONTENGONO I NUMERI
		primalunghezza=primacoppia.length
		secondalunghezza=secondacoppia.length
		terzalunghezza=quadrupla.length
		if ((primalunghezza=2)&&(primoslash=="/")&&(numero>=1)&&(numero<=31)&&(secondalunghezza=2)&&(secondoslash=="/")&&(numero1>=1)&&(numero1<=12)&&(quadrupla=4)&&(numero2>=1800)&&(numero2<=3000)) {
		// alert("BRAVO");
		}
		else
		{
		 alert("Formato data non valido");
		 document.getElementById(campodata).value = "gg/mm/aaaa";
		}
	}

	} 
