
function Form1_Validator(theForm)
{

  if ((theForm.T1.value == "")&&(theForm.T2.value == "")&&(theForm.T3.value == ""))
  {
    alert("Inserisci un dato valido per la ricerca");
    theForm.T1.value="";
	theForm.T1.focus();
    return (false);
  }

  if ((theForm.T1.value != "")&&(theForm.T1.value.length < 2))
  {
    alert("Inserire almeno 2 caratteri");
    theForm.T1.value="";
	theForm.T1.focus();
    return (false);
  }

  if ((theForm.T1.value != "")&&(theForm.T1.value.length > 50))
  {
    alert("Inserire max 50 caratteri");
    theForm.T1.value="";
	theForm.T1.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþ123'- \t\r\n\f";
  var checkStr = theForm.T1.value;
  var allValid = 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' possibile inserire solo caratteri alfabetici.");
    theForm.T1.value="";
	theForm.T1.focus();
    return (false);
  }
//  return (true);


//  if (theForm.T2.value == "")
//  {
//    alert("Inserisci un dato valido per la ricerca");
//    theForm.T2.focus();
//    return (false);
//  }

  if ((theForm.T2.value != "")&&(theForm.T2.value.length < 2))
  {
    alert("Inserire almeno 2 caratteri");
    theForm.T2.value="";
	theForm.T2.focus();
    return (false);
  }

  if ((theForm.T2.value != "")&&(theForm.T2.value.length > 50))
  {
    alert("Inserire max 50 caratteri");
    theForm.T2.value="";
	theForm.T2.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒšœŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþ'.- \t\r\n\f";
  var checkStr = theForm.T2.value;
  var allValid = 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' possibile inserire solo caratteri alfabetici");
    theForm.T2.value="";
	theForm.T2.focus();
    return (false);
  }
 // return (true);


 // if (theForm.T3.value == "")
 // {
 //   alert("Inserisci un dato valido per la ricerca.");
 //   theForm.T3.focus();
 //   return (false);
 // }

  if ((theForm.T3.value != "")&&(theForm.T3.value.length < 5))
  {
    alert("Inserire 5 caratteri numerici.");
    theForm.T3.value="";
	theForm.T3.focus();
    return (false);
  }

  if ((theForm.T3.value != "")&&(theForm.T3.value.length > 5))
  {
    alert("Inserire 5 caratteri numerici..");
    theForm.T3.value="";
	theForm.T3.focus();
    return (false);
  }

  var checkOK = "0123456789";
  var checkStr = theForm.T3.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  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 (ch == ".")
    {
      allNum += ".";
      decPoints++;
    }
    else
      allNum += ch;
  }
  if (!allValid)
  {
    alert("Digitare solo caratteri numerici.");
    theForm.T3.value="";
	theForm.T3.focus();
    return (false);
  }

  if (decPoints > 1)
  {
    alert("inserire un numero valido.");
    theForm.T3.value="";
	theForm.T3.focus();
    return (false);
  }
  //return (true);



 //if (theForm.T5.value == "")
 //{
 //  alert("Inserisci un dato valido per la ricerca.");
 //  theForm.T5.focus();
 //  return (false);
 // }
   
 //if ((theForm.T5.value.length != 0)&&(theForm.T5.value.length < 4))
  //{
   // alert("Inserire almeno 4 caratteri numerici.");
   // theForm.T5.value="";
 //	theForm.T5.focus();
  //  return (false);
  //}
  
 //if ((theForm.T5.value.length != 0)&&(theForm.T5.value.length > 6))
 // {
 //   alert("Inserire max 6 caratteri numerici.");
 //   theForm.T5.value="";
 //	theForm.T5.focus();
 //   return (false);
 // }
  
 // if ((theForm.T5.value.length != 0)&&(theForm.T5.value.length == 5))
 // {
 //   alert("Inserire 4 o 6 caratteri numerici.");
 //   theForm.T5.value="";
 //	theForm.T5.focus();
 //   return (false);
 // }

  
 // var checkOK = "0123456789";
 // var checkStr = theForm.T5.value;
 // var allValid = true;
 // var decPoints = 0;
 // var allNum = "";
 // 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 (ch == ".")
 //   {
 //     allNum += ".";
 //     decPoints++;
 //   }
 //   else
 //     allNum += ch;
 // }
 // if (!allValid)
 // {
 //   alert("Digitare solo caratteri numerici.");
 //   theForm.T5.value="";
 //	theForm.T5.focus();
 //   return (false);
 // }

  //if (decPoints > 1)
 // {
 //   alert("inserire un numero valido.");
 //   theForm.T5.value="";
 //	theForm.T5.focus();
 //   return (false);
 // }
  return (true);
}
