Example #1
0
  /// <summary>Given a name, optional email address, and optional comment, determines whether they constitute a valid
  /// user ID. Message boxes may be displayed to the user if any problems are found with the user ID. True is returned
  /// if the values should be used, and false if not.
  /// </summary>
  public static bool ValidateUserId(string realName, string email, string comment)
  {
    if(string.IsNullOrEmpty(realName))
    {
      MessageBox.Show("You must enter your name.", "Name required", MessageBoxButtons.OK, MessageBoxIcon.Error);
      return false;
    }
    else if(!string.IsNullOrEmpty(email) && !PGPUI.IsValidEmail(email))
    {
      MessageBox.Show(email + " is not a valid email address.", "Invalid email",
                      MessageBoxButtons.OK, MessageBoxIcon.Error);
      return false;
    }

    return true;
  }