Validating an email address

Today I will present you with the devious process to validate an email address. It's basicly the same way as with the URL, just a different regular expression.

PHP:
  1. function isValidEmail($email) {
  2.   if (!eregi("^([a-zA-Z0-9\._\-]+)@([a-zA-Z0-9\._\-]+)\\.([a-zA-Z]+)$", $email)) {
  3.     return false;
  4.   } else {
  5.     return true;
  6.   }
  7. }

Leave a Reply

You must be logged in to post a comment.