15 August 2012

Check TextBox value is in Email ID Format in C#.net

public  static  bool EmailAddressCheck(string emailAddress,int Mode)
        {
            bool functionReturnValue = false;
            if (Mode == 1)
            {
                string pattern = "^[a-zA-Z][\\w\\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\\w\\.-]*[a-zA-Z0-9]\\.[a-zA-Z][a-zA-Z\\.]*[a-zA-Z]$";
                Match emailAddressMatch = Regex.Match(emailAddress, pattern);
                if (emailAddressMatch.Success)
                {
                    functionReturnValue = true;
                }
                else
                {
                    functionReturnValue = false;
                    MessageBox.Show("This is not a Email Format");
                }
            }
            return functionReturnValue;
          
        }


1 comment:

Lakshmi Naraayanan said...

This comment has been removed by the author.