Xpode.com        Click here to Print this article.

Server side Email validation

Server side Email validation in asp.net

In mostly forms where user enter his email ids. There is need to verify the email format for user because mostly users enter sometime wrong format of email etc. so we are giving the solution for emails validation at server side:

				
public static bool IsEmail(string Email)
{
string strRegex = @"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}" +
@"\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" +
@".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";
Regex re = new Regex(strRegex);
if (re.IsMatch(Email))
return (true);
else
return (false);
}

Call this function when validating the value like:

if (IsEmail(Textbox1.Text))



http://
http://

Contributed by:
Rohit kakria
I am software developer, moderator of xpode.com

Resourse address on xpode.com
http://www.xpode.com/Print.aspx?Articleid=94

Click here to go on website