function validate_required(field,alerttxt)
{
	with (field)
	{
		if (value==null||value==""||value==undefined) {alert(alerttxt); field.focus(); return false}
		else {return true}
	}
}

function validate_email(field,alerttxt)
{
	with (field)
	{
		apos=value.indexOf("@");
		dotpos=value.lastIndexOf(".");
		if ((apos<1||dotpos-apos<2) && value.length!=0) {alert(alerttxt); return false;}
		else return true;
	}
}

function validate_form(thisform)
{
	with (thisform)
	{
		if (validate_required(nome,"Il nome è obbligatorio!")==false)  return false;
		else if (validate_required(cognome,"Il cognome è obbligatorio!")==false)  {cognome.focus(); return false}
		else if (validate_required(richiedente,"E' necessario specificare se sei un alunno, un genitore o un docente")==false)  {richiedente.focus(); return false}
		else if (validate_required(email,"Inserire l'email!")==false)  {email.focus(); return false}
		else if (validate_email(email,"Non è un indirizzo email valido!")==false) {email.focus(); return false;}
	//	else if (testo.value == ' ') {alert("Inserire gli argomenti richiesti!"); return false}
		else if (validate_token.value.length != 5) {alert("La stringa inserita non è corretta!"); validate_token.focus(); return false}
	}
}

