Validate Email Address
7
Validate Email Address
<?php
function IsValidEmail($strEmail)
{
// Validate the syntax
if (eregi("^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $strEmail))
{
return true;
}
return false;
}
?>
function IsValidEmail($strEmail)
{
// Validate the syntax
if (eregi("^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $strEmail))
{
return true;
}
return false;
}
?>






Your regexp is unfortunatly incomplete (doesn't match all possible addresses) but hey, there is as far as I'm concered only one which does (were situated here before it got removec; http://public.yahoo.com/~jfriedl/regex/email-unopt.pl) but yours matches a bit to few for my taste.
It won't match addresses such as james+blunt@example.com or james&blunt@example.com (they are both valid addresses).
Just some thoughts.
-----------------------
http://jiart.org/
My digital playground with it's own sandbox.
Well anyway, I love programming
-----------------------
Proud owner of scriptsentials.com and the Scriptsentials network.
It's really handy, yet so often forgotten.