function SubmitIt(mailform)
{

<!-- Ensure user enters a first name -->
    if (mailform.FirstName.value == "")
     {
      alert("Please enter your first name");
      mailform.FirstName.focus();
      return false;
     }

<!-- Ensure user enters a last name -->
    if (mailform.LastName.value == "")
     {
      alert("Please enter your last name");
      mailform.LastName.focus();
      return false;
     }

<!-- Ensure user enters an email address -->
    if (mailform.EmailAddress.value == "")
     {
      alert("Please enter your email address");
      mailform.EmailAddress.focus();
      return false;
     }

<!-- Check the email address -->
if (BadEmail(mailform.EmailAddress.value))
	{
	 alert("Please check your Email address. It appears to be incorrect.");
	 mailform.EmailAddress.focus();

         <!-- this "selects" (highlights) the contents -->
          mailform.EmailAddress.select();          
	  return false;
	}

<!-- Ensure user enters a confirmed email -->
    if (mailform.ConfirmedEmail.value == "")
     {
      alert("Please enter your confirmed email");
      mailform.ConfirmedEmail.focus();
      return false;
     }

<!-- Check the confirmed email address -->
if (BadcEmail(mailform.ConfirmedEmail.value))
	{
	 alert("Please check your Confirmed Email address. It appears to be incorrect.");
	 mailform.ConfirmedEmail.focus();

         <!-- this "selects" (highlights) the contents -->
          mailform.ConfirmedEmail.select();          
	  return false;
	}

if (NotEqualEmail(mailform.EmailAddress.value,mailform.ConfirmedEmail.value))
        {
         alert("Your email address was not confirmed.  Please re-enter.");
         return false;
        }

   return true;
}

<!-- This function returns true if the email address is bad. -->
<!-- Returns false if email address appears okay. -->

function BadEmail(EmailAddress)
{
	<!-- blank is bad -->
	if (EmailAddress == "") return true;

	<!-- need one @, and it can't be in first spot (0) -->
	var a = EmailAddress.indexOf("@");
	if (a < 1) return true;

	<!-- can't have 2 @'s -->
	if (EmailAddress.indexOf("@",a+1) != -1) return true;

	<!-- need a period, and at least 2 characters after -->
	p = EmailAddress.indexOf(".",a+2);
	if (p == -1 || p > EmailAddress.length-3) return true;

	<!-- these characters can't be anywhere in an address -->
	var bad = " /,;:";

        <!-- re-use "a" as counter -->
	for (a=0; a<5; a++)  
	{

        <!-- re-use "p" for one bad character -->
	  p = bad.charAt(a);
	  if (EmailAddress.indexOf(p) > -1) return true;
	}

	<!-- if we get here, it appears okay... so "Bad" is false: -->
	return false;
}

<!-- This function returns true if the email address is bad. -->
<!-- Returns false if email address appears okay. -->

function BadcEmail(ConfirmedEmail)
{
	<!-- blank is bad -->
	if (ConfirmedEmail == "") return true;

	<!-- need one @, and it can't be in first spot (0) -->
	var a = ConfirmedEmail.indexOf("@");
	if (a < 1) return true;

	<!-- can't have 2 @'s -->
	if (ConfirmedEmail.indexOf("@",a+1) != -1) return true;

	<!-- need a period, and at least 2 characters after -->
	p = ConfirmedEmail.indexOf(".",a+2);
	if (p == -1 || p > ConfirmedEmail.length-3) return true;

	<!-- these characters can't be anywhere in an address -->
	var bad = " /,;:";

        <!-- re-use "a" as counter -->
	for (a=0; a<5; a++)  
	{

        <!-- re-use "p" for one bad character -->
	  p = bad.charAt(a);
	  if (ConfirmedEmail.indexOf(p) > -1) return true;
	}

	<!-- if we get here, it appears okay... so "Bad" is false: -->
	return false;
}

function NotEqualEmail(EmailAddress,ConfirmedEmail)
{
	<!-- Not equal is bad -->
	if (EmailAddress != ConfirmedEmail) return true;
}