Click here to hide categories Click here to show left categories

User: Home          welcome : Guest          Log In / Register here     




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))

Share this article   |    Print    |    Article read by 3316 times
Author:
Rohit kakria
I am software developer, moderator of xpode.com
Related Articles:
Related Interview Questions: No related interview question