title: Why doesn't pressing ok in messagebox error message take you back to form1 instead of form2?
body: <p>I have an IF statement that validates an email. If its true, form2 closes and returns email address to form1. But if its false, it has a error message pop up and say 'enter correct email' and return to form2 which it doesn't. It just closes form2 automatically and goes back to form1. </p>
  
  <p>Form1</p>
  
  <pre><code>        private void btnRegister_Click(object sender, EventArgs e)
      {
          if (chkNewMember.Checked)
          {
              Email form = new Email();
              form.ShowDialog();
              lblDisplay.Text = form.validEmail;
          }
      }
  </code></pre>
  
  <p>Form2</p>
  
  <pre><code>public partial class Email : Form
  {
      public string validEmail;
      public Email()
      {
          InitializeComponent();
      }
  
      public void getEmail()
      {
          string email = txtEmail.Text;
          bool isEmail = Regex.IsMatch(email, @"\A(?:[a-z0-9!#$%&amp;'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&amp;'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z", RegexOptions.IgnoreCase);
  
          if (isEmail)
          {
              validEmail = email;
          }
          else
          {
              MessageBox.Show("Please enter a valid email address.", "Invalid Email", MessageBoxButtons.OK, MessageBoxIcon.Warning);
          }
      }
  
      private void btnSubmit_Click(object sender, EventArgs e)
      {
          getEmail();
          this.Close();
      }
  
      private void btnCancel_Click(object sender, EventArgs e)
      {
          this.Close();
      }
  </code></pre>