
var good;

function checkEmailAddress(field) 
{
  var goodEmail = field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
  if (goodEmail)
  {
	good = true
  } 
  else 
  {
	alert('Attenzione! Inserire un indirizzo e-mail valido.')
	field.focus()
	field.select()
	good = false
  }
}

function sendOff()
{
	textcheck = document.getElementById("telefono"); 
	if ((textcheck.value.length) < 3 ||  (textcheck.value == "- Inserisci il telefono -") )  
	{
		alert('Attenzione! Inserisci il telefono.')
		return
	} 
   telcheck = document.getElementById("testo"); 
	if ((telcheck.value.length < 1) || (telcheck.value == "- Inserisci il testo -") )
	{
		alert('Attenzione! Inserisci il testo del messaggio.')
		return
	} 
	
	if (!document.getElementById("consenso").checked) 
	{
		alert('Attenzione! Per continuare e necesario dare il consenso al trattamento dei dati personali.')
		return
	} 
	
	good = false

	checkEmailAddress(document.getElementById("email"))
	if (good)
	{
		document.getElementById("form_richiesta").submit();
	} 
}
