private void            LoginTB_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
        {
            var tb = sender as TextBox;

            if (e.Key == Key.Enter)
            {
                tb.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
                EmailTB.SelectAll();
            }
        }
Esempio n. 2
0
        private void EmailTB_Validating_1(object sender, CancelEventArgs e)
        {
            System.Text.RegularExpressions.Regex rEmail = new System.Text.RegularExpressions.Regex(@"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$");

            if (EmailTB.Text.Length > 0 && EmailTB.Text.Trim().Length != 0)
            {
                if (!rEmail.IsMatch(EmailTB.Text.Trim()))
                {
                    MessageBox.Show("Incorrect Email id");
                    EmailTB.SelectAll();
                    e.Cancel = true;
                }
            }
        }