I would appreciate some help validating an email address in PHP. The format for the email that I need is firstname.lastname@mohawkcollege.TLD
, .com
, .ca
, or .org
being valid TLDs.
My function is:
function validateEmail($email)
{
$regex = "/[a-zA-Z0-9_-.+]+@[a-zA-Z0-9-]+.[a-zA-Z]+/";
if (!preg_match($regex, $email))
{
return "<li>Email is in wrong format</li>"
}
}