Raghavendra
Joined: 21 Aug 2007 Posts: 222
|
Posted: Tue Dec 29, 2009 6:25 am Post subject: server side Email validation in ASP.Net with C# |
|
|
Hi All,
We can perform validations in two ways. one is Client side using scripting languages like java script and VB script. If the client side scripting is blocked by the user in browser settings, Our entire validation will be fail. To avoid this we need to prefer Server side validation also for the robustness of the application. Following is the sample code for email verification.
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);
}
Thanks & Regards,
Raghavendra K. |
|