	function checkDate(campo, messaggio) {
		var x=campo.value.split("/");
		if ( x.length != 3 ) {
			alert(messaggio);
			return false;
		} else {
			giorno = parseInt(x[0], 10);
			if(isNaN(giorno)) {
				alert(messaggio);
				return false;
			}
			mese = parseInt(x[1], 10);
			if(isNaN(mese)) {
				alert(messaggio);
				return false;
			}
			anno = parseInt(x[2], 10);
			if(isNaN(anno)) {
				alert(messaggio);
				return false;
			}
			if ( !isValidDate(giorno, mese, anno) ) {
				alert(messaggio);
				return false;
			}
			return true;
		}
	}
		
    function isValidDate(d, m, y) {
        if (d < 1 || m < 1 || m > 12 || y < 1900) {
	        return false;
        }
        if (m == 2) {
            if (isLeapYear(y)) {
	            return d <= 29;
        	} else { 
	        	return d <= 28;
        	}
        } else if (m == 4 || m == 6 || m == 9 || m == 11) {
            return d <= 30;
    	} else {
            return d <= 31;
        }
    }
    
    function isLeapYear(y) {
        return y % 4 == 0 && (y % 400 == 0 || y % 100 != 0);
    }