Email Check

They have: 218 posts

Joined: Apr 2001

The following email check:

function emailCheck($intext){
     $theresults = ereg("^[^@ ]+@[^@ ]+\.[^@ \.]+$", $intext, $trashed);
if ($theresults){
    return true;
   }
'

...may be excluding some valid email addresses...How can it be improved?

Thanks,

TM

Busy's picture

He has: 6,151 posts

Joined: May 2001

what I use is

function check_mail($given_email) {
$given_email = trim($given_email);
if (!eregi("^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3}$", $given_email)) {
$messed_up .= "email ";
}
return $messed_up;
}

the messed_up result is just part of the whole form validation

Greg K's picture

He has: 2,145 posts

Joined: Nov 2003

In my search for expressions, I came across this site with many expressions:

http://regexlib.com/DisplayPatterns.aspx

I have bookmarked it for use in future and thought you and others here might like it.

-Greg

openmind's picture

He has: 945 posts

Joined: Aug 2001

I use a cracking extension for DW MX that not just checks bad email very well but does a whole bunch of other stuffe.

BTW, it's free!

http://www.yaromat.com/dw/?ex=Check%20Form%20MX

Greg K's picture

He has: 2,145 posts

Joined: Nov 2003

Off Topic: I loved their (yaromat's) Mac OS 8 emulator off of their home page, I once went to each computer in a lab and browsed each one to it. Should have seen the looks on student's faces when they came in. LOL

(note if you try it, I think full screen effect works only in IE on windows, if I remember right, netscape didn't fully fill the screen)

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.