Umbraco: How to validate Email address in umbraco by c#.

For validate email address use below function. Pass email address to IsValidEmail function.

Make sure you are have used this name space

</span></span></span></strong></span>

<span style="font-size: large;"><strong><span style="color: #000000;"><span style="font-family: Consolas,sans-serif;"><span style="font-size: small;">
    <strong>using System.Text.RegularExpressions;
</strong>
        /// <summary>
        /// Validate Email Address
        /// </summary>
        /// <param name="email"></param>
        /// <returns></returns>
        private static bool IsValidEmail(string email)
        {
            var r = new Regex(@"^([0-9a-zA-Z]([-\.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$");

            return !string.IsNullOrEmpty(email) && r.IsMatch(email);
        }

Another Umbraco Article

Advertisements

2 thoughts on “Umbraco: How to validate Email address in umbraco by c#.

  1. Pingback: Create your first Rss Feed Burner in umbraco | [Code Destination]

  2. Pingback: Install umbraco manually. | [Code Destination]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s