<!-- // Version 1.3 -- June 15, 2004. Developed by Patrick Finnegan/Snitily Carr.

function CheckString(strName)
  {if (strName.value.length > 0) {return true;} else {return false;}}


function CheckEmail(strName)
  {if (strName.value.length > 0)
    {if ((strName.value.search("@") != -1) && (strName.value.search("\\.") != -1)) {return true;}
    else {return false}}
  else {return false;}}


function CheckPosNumber(strName)
  {if (parseFloat(strName.value) >= 0) {return true;} else {return false;}}


function CheckNumber(strName)
  {if (strName.value.charAt(0) == '-') {strName = strName.value.substr(1, strName.value.length-1);}
  else {strName = strName.value;}
  if (parseFloat(strName) >= 0) {return true;}
  else {return false;}}


function CheckDropDown(strName)
  {if (strName.options[0].selected) {return false;} else {return true;}}


function CheckRadio(strName)
  {i = 0;
  x = 0
  while (i < (strName.length))
    {if (strName[i].checked) {return true;}
    i = i + 1;}
  return false;}


function CheckDate(dtmName)
  {if (dtmName.value.length <= 0) {return false;}
  else {if (Date.parse(dtmName.value) != Date.parse(dtmName.value)) {return false;}}}


function CheckCCNum(strCCNum)
  {intLength = strCCNum.value.length;
  var strTemp = '';
  for (i = 0; i <= intLength; i++)
    {strChar = strCCNum.value.charAt(i);
    if (parseFloat(strChar) || strChar == '0') {strTemp = strTemp + strChar;}}

  if (document.fCC.type.value == "Amex") {intTestLen = 10;}
  else {intTestLen = 16;}
  if (strTemp.length >= intTestLen)
    {strCCNum.value = strTemp;
    return true;}
  else
    {return false;}}


function CheckPhone(strPhone)
  {intLength = strPhone.value.length;
  var strTemp = '';
  for (i = 0; i <= intLength; i++)
    {strChar = strPhone.value.charAt(i);
    if (parseFloat(strChar) || strChar == '0'){strTemp = strTemp + strChar;}}
  if ((strTemp.length == 11) && (strTemp.charAt(0) == '1'))
    {strTemp = strTemp.substr(1, 11);}
  if (strTemp.length == 10)
    {strPhone.value = '(' + strTemp.substr(0, 3) + ') ' + strTemp.substr(3, 3) + '-' + strTemp.substr(6, 4);
    return true;}
  else {return false;}}


function CheckSSN(strSSN)
  {intLength = strSSN.value.length;
  var strTemp = '';
  for (i = 0; i <= intLength; i++)
    {strChar = strSSN.value.charAt(i);
    if (parseFloat(strChar) || strChar == '0') {strTemp = strTemp + strChar;}}
  if (strTemp.length == 9)
    {strSSN.value = strTemp.substr(0, 3) + '-' + strTemp.substr(3, 2) + '-' + strTemp.substr(5, 4);
    return true;}
  else {return false;}}


function CheckZip(strZip)
  {intLength = strZip.value.length;
  var strTemp = '';
  for (i = 0; i <= intLength; i++)
    {strChar = strZip.value.charAt(i);
    if (parseFloat(strChar) || strChar == '0') {strTemp = strTemp + strChar;}}
  if (strTemp.length == 5)
    {strZip.value = strTemp;
    return true;}
  else if (strTemp.length == 9)
    {strZip.value = strTemp.substr(0, 5) + '-' + strTemp.substr(5, 4);
    return true;}
  else {return false;}}


function CheckIP(strIP)
  {if ((strIP.value.length < 7) || (strIP.value.length > 15)) {return false;}
  else
    {arrIP = strIP.value.split('.');
    if (arrIP.length == 4) {return true;}
    else {return false;}}}

//-->

/* Add the following to the HEAD of your HTML page. Replace FORM NAME with the name of your form. Replace FORM ACTION with the page the form action. Replace FIELDNAME with the name of the field you are validating.
<script language="JavaScript" src="/javascript/FormVal.js"></script>
<script language="JavaScript">
<!--
  function FormVal()
    {var strAlert = "";
    var fAction = "FORM ACTION";

    if (CheckString(document.FORMNAME.FIELDNAME) == false) {strAlert = strAlert + "Error message.\n";}
    if (CheckEmail(document.FORMNAME.FIELDNAME) == false) {strAlert = strAlert + "Error message.\n";}
    if (CheckPosNumber(document.FORMNAME.FIELDNAME) == false) {strAlert = strAlert + "Error message.\n";}
    if (CheckNumber(document.FORMNAME.FIELDNAME) == false) {strAlert = strAlert + "Error message.\n";}
    if (CheckDropDown(document.FORMNAME.FIELDNAME) == false) {strAlert = strAlert + "Error message.\n";}
    if (CheckRadio(document.FORMNAME.FIELDNAME) == false) {strAlert = strAlert + "Error message.\n";}
    if (CheckDate(document.FORMNAME.FIELDNAME) == false) {strAlert = strAlert + "Error message.\n";}
    if (CheckCCNum(document.FORMNAME.FIELDNAME) == false) {strAlert = strAlert + "Error message.\n";}
    if (CheckPhone(document.FORMNAME.FIELDNAME) == false) {strAlert = strAlert + "Error message.\n";}
    if (CheckSSN(document.FORMNAME.FIELDNAME) == false) {strAlert = strAlert + "Error message.\n";}
    if (CheckZip(document.FORMNAME.FIELDNAME) == false) {strAlert = strAlert + "Error message.\n";}
    if (CheckIP(document.FORMNAME.FIELDNAME) == false) {strAlert = strAlert + "Error message.\n";}

    if (strAlert == "")
      {document.FORMNAME.action = fAction;
      document.FORMNAME.submit();}
    else
      {alert(strAlert);}}
//-->
</script>
*/

/* Add the following to the FORM of your HTML page. Replace FORM NAME with the name of your form.
<form name="FORMNAME" action="javascript:void(0);" method="post" onSubmit="FormVal()">
<input type="button" value="Submit" onClick="FormVal()">
*/