private static bool ValidateEmail(string email)
{
try
{
string TextToValidate = email;
Regex expression = new Regex(@"\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}");
// test email address with expression
if (expression.IsMatch(TextToValidate))
{
// is valid email address
return true;
}
else
{
// is not valid email address
return false;
}
}
catch (Exception)
{
throw;
}
}
{
try
{
string TextToValidate = email;
Regex expression = new Regex(@"\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}");
// test email address with expression
if (expression.IsMatch(TextToValidate))
{
// is valid email address
return true;
}
else
{
// is not valid email address
return false;
}
}
catch (Exception)
{
throw;
}
}
No comments:
Post a Comment