Check Email formatting in asp.net c#(code behind).

Aman Sharma
0

 Here is function to check email is in proper format or not, email is valid or not.

 

public bool CheckEmail(string Email_Address)

        {

            string pattern = @"^[a-z][a-z|0-9|]*([_][a-z|0-9]+)*([.][a-z|" +

 

                @"0-9]+([_][a-z|0-9]+)*)?@[a-z][a-z|0-9|]*\.([a-z]" +

 

                @"[a-z|0-9]*(\.[a-z][a-z|0-9]*)?)$";

 

            System.Text.RegularExpressions.Match match = Regex.Match(Email_Address, pattern, RegexOptions.IgnoreCase);

 

 

            if (!match.Success)

            {

                return false;

 

            }

            else

            {

 

                return true;

            }

 

        }

 

We’ll send entered email Id as a parameter to this function & it will return true or false. We can show message as per our requirement if it returns false.

Post a Comment

0Comments
Post a Comment (0)

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !