TextBox Validation for Email address format

TextBox Control :
Represents a control that can be used to display or edit unformatted text. This control has additional functionality that is not found in the standard Windowstext box control, including multiline editing and password character masking.
TextBox Validation for Email address format :
Email address will be in a perticular format. Every email id will have @ symbol, that is the rule

for validating the email address. In the address after @ symbol the Domain name must be
added. The perfect email addres format will be like bellow..
Email address  formate is   <username>@<Domain name>
Domain names like .com, .net, in, .org etc..

Event :- This code should write in TextBox Leave event.

            string s = "[a-z0-9A-z]@[a-zA-z0-9 ]*[.]";
            string s1 = textBox4.Text.ToString();
            Match aa = Regex.Match(s1, s);
        if(aa.Success)
            {
                errorProvider1.SetError(textBox4, "");
            }
            else            {
                errorProvider1.SetError(textBox4, "mail id not in correct format");
             }
           
I hope the reguller expression given above will usefull for you.

2 comments:

  1. This post is good enough to make somebody understand this amazing thing, and I’m sure everyone will appreciate this interesting things.
    know more about janta khoj

    ReplyDelete
  2. I can see that you are an expert at your field! I am launching a website soon, and your information will be very useful for me.. Thanks for all your help and wishing you all the success in your business. www.verifications.io

    ReplyDelete