Email Validator


/ Published in: C#

A simple utility method to validate an Inputted Email Address.


Copy this code and paste it in your HTML
  1. public static bool IsValidEmail(string email)
  2. {
  3. string pattern = @"^(([^<>()[\]\\.,;:\[email protected]\""]+"
  4. + @"(\.[^<>()[\]\\.,;:\[email protected]\""]+)*)|(\"".+\""))@"
  5. + @"((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}"
  6. + @"\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+"
  7. + @"[a-zA-Z]{2,}))$";
  8. Regex regex = new Regex(pattern);
  9. return regex.IsMatch(email);
  10. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.