function validateDirectory(directoryForm)
{ var tempStr = trim(directoryForm.Last.value);
  if(!tempStr.match(/^[A-Za-z]+(?: {0,1}[A-Za-z]+)*(?:-[A-Za-z]+(?: {0,1}[A-Za-z]+)*)*$/))
  { alert("Last cannot be empty, must contain at least one letter, and may only contain letters, hyphens, and spaces");
    return false;
  }
  directoryForm.Last.value = tempStr;
  tempStr = trim(directoryForm.First.value);
  if(!tempStr.match(/^[A-Za-z]+(?: {0,1}[A-Za-z]+)*(?: & [A-Za-z]+(?: {0,1}[A-Za-z]+)*){0,1}$/))
  { alert("First cannot be empty, must contain at least one letter, and may only contain letters, spaces, and an ampersand (&)");
    return false;
  }
  directoryForm.First.value = tempStr;
  var childStr = trim(directoryForm.Children.value);
  if(childStr!="")
  { var children = childStr.split(",");
    for(var i=0; i<children.length; i++)
    { children[i] = trim(children[i]);
      if(!children[i].match(/^[A-Za-z]+(?: {0,1}[A-Za-z]+)*$/))
      { alert("Each child's name must be separated by a comma (if more than one child), must contain at least one letter, and may only contain letters and spaces");
        return false;
      }
    }
    directoryForm.Children.value = children.join(",");
  }
  directoryForm.Address.value = trim(directoryForm.Address.value);
  directoryForm.City.value = trim(directoryForm.City.value);
  tempStr = trim(directoryForm.State.value);
  if(tempStr!="" && !tempStr.match(/^[A-Za-z]{2}$/))
  { alert("State must be a two-letter abbreviation");
    return false;
  }
  directoryForm.State.value = tempStr;
  tempStr = trim(directoryForm.Zip.value);
  if(tempStr!="" && !tempStr.match(/^\d{5}$/))
  { alert("Zip must be 5 numbers");
    return false;
  }
  directoryForm.Zip.value = tempStr;
  tempStr = trim(directoryForm.Phone.value);
  if(tempStr!="" && !tempStr.match(/^[2-9]\d{2}[2-9]\d{6}$/))
  { alert("Phone must be 10 numbers");
    return false;
  }
  directoryForm.Phone.value = tempStr;
  tempStr = trim(directoryForm.Cell.value);
  if(tempStr!="" && !tempStr.match(/^[2-9]\d{2}[2-9]\d{6}$/))
  { alert("Cell must be 10 numbers");
    return false;
  }
  directoryForm.Cell.value = tempStr;
  var emailStr = trim(directoryForm.Email.value);
  if(emailStr!="")
  { var emails = emailStr.split(",");
    for(var i=0; i<emails.length; i++)
    { emails[i] = trim(emails[i]);
      if(!emails[i].match(/^[A-Za-z0-9._%+-]+@(?:[A-Za-z0-9-]+\.)+[A-Za-z]{2,4}$/))
      { alert("All e-mail addresses must have a valid format");
        return false;
      }
    }
    directoryForm.Email.value = emails.join(",");
  }
  if(useTemp)
  { return confirm("Are you sure you want to request that this information be added to the directory?");
  }
  else
  { return confirm("Are you sure you want to submit this information (old values cannot be recovered once they are overwritten)?");
  }
}

function trim(str)
{ return str.replace(/^\s+|\s+$/g,"");
}
