Validate an email address.


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

The following function does a very simple check on the supplied string to help ensure it is a valid email address.


Copy this code and paste it in your HTML
  1. <?php
  2. function validEmail($email) {
  3. if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$",$email))
  4. return TRUE;
  5. else
  6. return FALSE;
  7. }
  8. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.