Tuesday, October 25, 2016

Check Valid Email from String c#

Hi All,

Please find the Code for Checking Valid Email from String

bool getValidationChecked = checkValidEmail(test@test.com);

public static bool checkValidEmail(string emailID)
        {
            bool validEmailAddress = false;
            string[] arrayAdditionalTo = emailID.Split(';');
            foreach (string word in arrayAdditionalTo)
            {
                string pattern = null;
                pattern = "^([0-9a-zA-Z]([-\\.\\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\\w]*[0-9a-zA-Z]\\.)+[a-zA-Z]{2,9})$";

                if (Regex.IsMatch(word, pattern))
                {
                    validEmailAddress = true;
                }
                else
                {
                    return false;
                }
            }
            if (validEmailAddress)
            {
                return true;
            }
            return false;
}

No comments:

Post a Comment

Day 11 - Customizing Option Sets Dropdown Fields with JavaScript

  In this Blog, we will see how to Customizing Option Sets Dropdown Fields with JavaScript label1 = formContext.getAttribute( "bosch_op...