private void MskCep_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (EmailText.Enabled) { EmailText.Focus(); } else { ReturnButton.Focus(); } } }
//Validating email address private void EmailText_Validating(object sender, CancelEventArgs e) { try { var mail = new MailAddress(EmailText.Text); bool isValidEmail = mail.Host.Contains("."); if (!isValidEmail) { MessageBox.Show("Not a valid e-mail address!"); EmailText.Focus(); } } catch (Exception) { MessageBox.Show("Not a valid e-mail address!"); EmailText.Focus(); } }
public LoginPage() { InitializeComponent(); EmailText.Focus(); }