March 17, 2011

TextBox Validation for Email address format

 private void txtMail_Leave(object sender, EventArgs e)
        {
            string s = "[a-z0-9A-z]@[a-zA-z0-9 ]*[.]";
            string s1 = txtMail.Text.ToString();
            Match aa = Regex.Match(s1, s);
            if (aa.Success)
            {
              
            }
            else
            {
                MessageBox.Show("E-mail Address is not in correct format");
                txtMail.Text = "";
                txtMail.Focus();
            }
        }

No comments:

Post a Comment