﻿function FrontPage_Form1_Validator(theForm)
{

  if (theForm.nomeCliente.value == "")
  {
    alert("Inserire un valore per il campo Nome.");
    theForm.nomeCliente.focus();
    return (false);
  }

  if (theForm.cognomeCliente.value == "")
  {
    alert("Inserire un valore per il campo Cognome.");
    theForm.cognomeCliente.focus();
    return (false);
  }

  if (theForm.mailCliente.value == "")
  {
    alert("Inserire un valore per il campo e-mail.");
    theForm.mailCliente.focus();
    return (false);
  }
  
  var espressione = /^[_a-z0-9+-]+(\.[_a-z0-9+-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$/;

  mailCliente = theForm.mailCliente.value;

  if (!espressione.test(mailCliente))
  {
	alert("Inserire un'account e-mail valido.");
	theForm.mailCliente.focus();
    return (false);
  }

  if (theForm.messaggioCliente.value == "")
  {
    alert("Inserire un valore per il campo Messaggio.");
    theForm.messaggioCliente.focus();
    return (false);
  }
  return (true);
}
