View Single Post
  #7 (permalink)  
Old November 23rd, 2004, 01:45 PM
richard.york's Avatar
richard.york richard.york is offline
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

> I was wondering if there is a way to check for spaces inside an email address?

There are several ways of validating an email address (from a syntactical standpoint).

I've used something like this in the past, and it works pretty well.

Code:
function is_email($email)
{
    return ereg("^[^@ ]+@[^@ ]+\.[^@ ]+$", $email);
}
If you just want to check for the presence of space, do something like the following:
Code:
if (strstr(trim($email), ' '))
{
    // The email contains single space characters
}
else
{
    // The email does not contain space characters
}
(This doesn't find tabs BTW)

HTH!

Regards,
Rich

--
[http://www.smilingsouls.net]
Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design
Reply With Quote