Check the typed email id

Type this code on the textBox leave event...

        System.Text.RegularExpressions.Regex rEMail =

            new System.Text.RegularExpressions.Regex

            (@"^[a-zA-Z][\w\.-]{2,28}[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$");

        if (textBox3.Text.Length > 0)

        {

            if (!rEMail.IsMatch(textBox3.Text))

            {

                MessageBox.Show("E-Mail expected", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                textBox3.SelectAll(); e.Cancel = true;

            }

        }

Ebook Download
View all
Learn
View all