﻿<!--
function FrontPage_Form1_Validator(theForm)
{

  if (theForm.description.value == "")
  {
    alert("Please enter a value for the \"description\" field.");
    theForm.description.focus();
    return (false);
  }

  if (theForm.description.value.length < 10)
  {
    alert("Please enter at least 10 characters in the \"description\" field.");
    theForm.description.focus();
    return (false);
  }

  if (theForm.amount.value == "")
  {
    alert("Please enter a value for the \"Payment Amount\" field.");
    theForm.amount.focus();
    return (false);
  }

  if (theForm.amount.value.length < 4)
  {
    alert("Please enter at least 4 characters in the \"Payment Amount\" field.");
    theForm.amount.focus();
    return (false);
  }

  if (theForm.amount.value.length > 8)
  {
    alert("Please enter at most 8 characters in the \"Payment Amount\" field.");
    theForm.amount.focus();
    return (false);
  }

  var checkOK = "0123456789-.";
  var checkStr = theForm.amount.value;
  var allValid = true;
  var validGroups = 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("Please enter only digit characters in the \"Payment Amount\" field.");
    theForm.amount.focus();
    return (false);
  }

  if (decPoints > 1 || !validGroups)
  {
    alert("Please enter a valid number in the \"amount\" field.");
    theForm.amount.focus();
    return (false);
  }

  var chkVal = allNum;
  var prsVal = parseFloat(allNum);
  if (chkVal != "" && !(prsVal > 10 && prsVal <= 4500))
  {
    alert("Please enter a value greater than \"10\" and less than or equal to \"4500\" in the \"Payment Amount\" field.");
    theForm.amount.focus();
    return (false);
  }
  return (true);
}

