// JavaScript Document
 
function controllo_dati_inseriti_invio_emal(theForm)
{

//...........................................................................................
  if (theForm.nome.value == "")
  {
    alert("Inserire un valore per il campo \"Nome\".");
    theForm.nome.focus();
    return (false);
  }

  

  if (theForm.nome.value.length < 4)
  {
    alert("Inserire un nome valido nel campo \"Nome\".");
    theForm.nome.focus();
    return (false);
  } 
 //..................................................................................................

 if (theForm.ric_info.value == "")
  {
    alert("Formulare una domanda nel campo \"Richiesta informazioni\".");
    theForm.ric_info.focus();
    return (false);
  }
  
  if (theForm.ric_info.value.length < 5)
  {
    alert("Formulare correttamente la richiesta informazioni.");
    theForm.ric_info.focus();
    return (false);
  }
  
  if (theForm.ric_info.value.length > 500)
  {
    alert("Inserire al massimo 500 caratteri nel campo \"Richiesta informazioni\".");
    theForm.ric_info.focus();
    return (false);
  }
//......................................................................
 
  if ((theForm.recap_telefon.value == "" ) & (theForm.email.value == ""))
  {
    alert("Inserire  un recapito telefonico, oppure un inndirizzo email.");
    theForm.recap_telefon.focus();
    return (false);
 }
  
 if (theForm.recap_telefon.value != "")
   {
		 if (theForm.recap_telefon.value.length < 5)
	  {
		alert("Il recapito telefonico inserito non è valido.");
		theForm.recap_telefon.focus();
		return (false);
	  }
					var checkOK = " 0123456789";
					var checkStr = theForm.recap_telefon.value;
					var allValid = true;
					var validGroups = true;
					for (i = 0;  i < checkStr.length;  i++)
					{
						ch = checkStr.charAt(i);
							for (j = 0;  j < checkOK.length;  j++)
							if (ch == checkOK.charAt(j))
								break;
							if (j == checkOK.length)
							{
							allValid = false;
							break;
							}
					}
				  
					if (!allValid) 
					{
						alert("Il recapito telefonico inserito non è valido.");
						theForm.recap_telefon.focus();
						return (false);
					}   
 }

//.................................................................




}
