How to validate the Phone Number and Email id
  • hi buddies to i found out how to validate the phone number and email id in textbox

    i hope it will use all developers

    using System.Text.RegularExpressions;//namespace

    private void ContactNotextBox_Leave(object sender, EventArgs e)


                Regex validator = new Regex("(7|8|9){1}[0-9]{9}");

                string match = validator.Match(ContactNotextBox.Text).Value.ToString();

                if (match.Length > 10 || match.Length < 10)


                    MessageBox.Show("Invalid Mobile Number, It Should be 10 digits !!""Project Shedule - Employee"MessageBoxButtons.OK, MessageBoxIcon.Error);

                    ContactNotextBox.Text = "";




      private void EmailIdtextBox_Leave(object sender, EventArgs e)


                System.Text.RegularExpressions.Regex _email = 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 (EmailIdtextBox.Text.Length > 0)


                    if (!_email.IsMatch(EmailIdtextBox.Text))


                        MessageBox.Show("Enter a valid Email-Address!""Project Shedule - Employee"MessageBoxButtons.OK, MessageBoxIcon.Error);

                        EmailIdtextBox.Text = "";





Howdy, Stranger!

It looks like you're new here. If you want to get involved, or you want to Ask a new Question, Please Login or Create a new Account by Clicking below

Login with Facebook


Popular Posts of the Week

Top Posters Weekly

Optimum Creative