Check University Email (.edu)


/ Published in: PHP

**Example of use:**

if (!isUniversityEmail('[email protected]'))
exit('You must have a valid and .edu email address to register for an account.');


Copy this code and paste it in your HTML
  1. /**
  2.  * @title Check if it is a valid and university email address.
  3.  *
  4.  * @author Pierre-Henry Soria <[email protected]>
  5.  * @copyright (c) 2013, Pierre-Henry Soria. All Rights Reserved.
  6.  * @param string $sEmail
  7.  * @return boolean
  8.  */
  9. function isUniversityEmail($sEmail)
  10. {
  11. return preg_match('/^[a-z0-9_\-]+(\.[_a-z0-9\-]+)*@([_a-z0-9\-]+\.)+edu$/i', $sEmail);
  12. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.