﻿    function FormValidator(theForm,felder)
    {
      
      var feldName = "";
      var Feld = felder.split(",");
      
      for (i = 0; i <= Feld.length-1; i++)
      {
          feldName = Feld[i];
      
          //alert(feldName);
          if (theForm[feldName] )
          {
              if (theForm[feldName].value == "")
              {
                alert("Prego compilare la casella " + feldName + ".");
                theForm[feldName].focus();
                return (false);
              }
          }
      }
      
      //document.getElementsByClassName("Valid")[ 0 ];
      if (theForm.Mail.value == "")
      {
          alert("Prego inserire il Vostro indirizzo e-mail.");
          theForm.Mail.focus();
          return (false);
      }
          
      if (theForm.Mail.value != "")
      {
        
          var x = theForm.Mail.value;
          var y = x.search("@");
                
          if (y == -1)
          {
              alert("Verificate il Vostro indirizzo e-mail.");
              theForm.Mail.focus();
              return (false);
          }
                
      }
    
      return (true);

    }