Validate email address


/ Published in: Other
Save to your folder(s)



Copy this code and paste it in your HTML
  1. /**
  2. * Validate email address
  3. * @param string $email Email address to validate
  4. * @return bool Returns TRUE if valid
  5. */
  6. public static function validate($email) {
  7. return preg_match("/^[A-Za-z0-9_!#$%*/?|^{}`~&'+-=]+(.[A-Za-z0-9_!#$%*/?|^{}`~&'+-=]+)*@[A-Za-z0-9-]+(.[A-Za-z0-9-]+)*(.[A-Za-z0-9-]{2,6})$/", $email);
  8. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.