Posted By

jprochazka on 10/02/10


Tagged

validation


Versions (?)

Validate an email address.


 / Published in: PHP
 

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

  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  

You need to login to post a comment.