

/* ======================================================================
FUNCTION: 	convalida di un modulo

INPUT:	all'invio		

DESC: consente l'invio del form con tutti i campi correttamente
      compilati
      
Autore: l.bragalone@libero.it						
====================================================================== */


function Verificacons(theForm){

re  =/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$//* imposto l'espressione*/

  if (theForm.nomecognome.value == ""&&theForm.azienda.value == "")
  {
    alert("Inserire il \"Nome e Cognome\" oppure il nome della \"Azienda o Organizzazione\".");
    theForm.nomecognome.focus();
    return (false);
  }
  

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ- \t\r\n\f";
  var checkStr = theForm.nomecognome.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("E' stato inserito un carattere non valido nel campo \"Nome e Cognome\"!\nE' possibile inserire solo lettere");
    theForm.nomecognome.focus();
    theForm.nomecognome.select();
    return (false);
  }
  

  if (theForm.citta.value == "")
  {
    alert("Inserire il nome della \"Città\"");
    theForm.citta.focus();
    return (false);
  }
  
  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ- \t\r\n\f";
  var checkStr = theForm.citta.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("E' stato inserito un carattere non valido nel campo \"Città\"!\nE' possibile inserire solo lettere");
    theForm.citta.focus();
    theForm.citta.select();
    return (false);
  }
  
if (theForm.cap.value == "")
  {
    alert("Non è stato inserito il\"C.A.P.\"");
    theForm.cap.focus();
    return (false);
  } 
    
  var checkOK = "0123456789\t\r\n\f";
  var checkStr = theForm.cap.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("E' stato inserito un carattere non valido nel campo \"C.A.P.\"!\nE' possibile inserire solo numeri");
    theForm.cap.focus();
    theForm.cap.select();
    return (false);
  }
  
   if (theForm.indirizzo.value == "")
  {
    alert("Non è stato inserito \"l'indirizzo\"");
    theForm.indirizzo.focus();
    return (false);
  } 
    
  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ0123456789,-. \t\r\n\f";
  var checkStr = theForm.indirizzo.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("E' stato inserito un carattere non valido nel campo \"Indirizzo\"!\nE' possibile inserire solo lettere e numeri");
    theForm.indirizzo.focus();
    theForm.indirizzo.select();
    return (false);
  }
  
  if (theForm.partitacf.value == "")
  {
    alert("Inserire la partita IVA o il Codice Fiscale");
    theForm.partitacf.focus();
    return (false);
  }
  
  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789,.- \t\r\n\f";
  var checkStr = theForm.partitacf.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("E' stato inserito un carattere non valido nel campo \"P.IVA o C.F.\"!\nE' possibile inserire solo lettere e numeri");
    theForm.partitacf.focus();
    theForm.partitacf.select();
    return (false);
  }
  
 if (theForm.quesito.value == "")
  {
    alert("Il campo \"Comunicazioni\" è vuoto!");
    theForm.quesito.focus();
    return (false);
  }
 
 if(theForm.consenso[0].checked ==true ) {

      alert('Per le disposizioni vigenti in materia abbiamo bisogno\ndel consenso al trattamento dei dati personali.');
                             return false
        if(theForm.consenso[0].checked==false)
                             return true
                           
  }     
        if(re.test(theForm.email.value)){     
                             return true
                     
    }
      alert("Indirizzo di posta elettronica non valido")
                theForm.email.focus()            
                theForm.email.select()         
                             return false  
}

