function checkcharset(text) {
        if (text.indexOf(";") > -1 || text.indexOf(":") > -1 || text.indexOf("," ) > -1 || text.indexOf("'") > -1) return 1;
        else return 0;
}

function mand(text,name) {
        text = text.split(" ")[0];
        if (!text) {
                alert("Immettere ["+name+"]");
                return 1;
        }
        else return 0;
}

function checkmand(text,name) {
        if (checkcharset(text)) {
                alert("Parametro ["+name+"] non valido, controllare");
                return 1;
        }
        if (mand(text, name)) return 1;
        return 0;
}

function checkmail(text,name) {
	if (checkcharset(text)) {
                alert("Parametro ["+name+"] non valido, controllare");
                return 1;
	}
	if (text.indexOf("@") == -1 || text.indexOf(".") == -1) {
		alert("Parametro ["+name+"] non valido, controllare");
		return 1;
	}
	return 0;
}

function mandnum(num, name) {
        if (isNaN(Number(num))) {
                alert("Parametro ["+name+"] non valido, controllare");
                return 1;
        }
        return 0;
}

function manddate(text, name) {
        error=0;
        error = checkcharset(text);
        if (text.length != 10) error=2;
        if (text.substr(2,1) != "/" || text.substr(5,1) != "/") error=3
        day = parseInt(text.substr(0,2),10);
        mon = parseInt(text.substr(3,2),10);
        yea = parseInt(text.substr(6,4),10);

        if (error > 0) {
                alert("Parametro ["+name+"] non valido, controllare ");
                return 1;
        }
        return 0;
}
