Connecting Tech Pros Worldwide Help | Site Map

Email validation with multiple dots in domain name

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 01:36 AM
JDJones
Guest
 
Posts: n/a
Default Email validation with multiple dots in domain name

I have a script that uses the following eregi to check for a valid email
address:

if (!eregi("^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,4}$", $email)) {
print_error("your <b>email address</b> is invalid");
}

While this works fine on most email addresses, it will not allow anyone
who has more than one dot in their domain name (like me@myisp.co.uk) to
submit. How can I change this to allow multiple dots in the domain?

Thanks.


  #2  
Old July 17th, 2005, 01:36 AM
Justin Koivisto
Guest
 
Posts: n/a
Default Re: Email validation with multiple dots in domain name

JDJones wrote:
[color=blue]
> I have a script that uses the following eregi to check for a valid email
> address:
>
> if (!eregi("^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,4}$", $email)) {
> print_error("your <b>email address</b> is invalid");
> }
>
> While this works fine on most email addresses, it will not allow anyone
> who has more than one dot in their domain name (like me@myisp.co.uk) to
> submit. How can I change this to allow multiple dots in the domain?[/color]

eregi("^[_\.0-9a-z-]+@([0-9a-z][0-9a-z.-]+\.)+[a-z]{2,4}$", $email)

--
Justin Koivisto - spam@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.

  #3  
Old July 17th, 2005, 01:36 AM
Tim Van Wassenhove
Guest
 
Posts: n/a
Default Re: Email validation with multiple dots in domain name

On 2003-12-11, JDJones <seebelow@sprynet.com> wrote:[color=blue]
> I have a script that uses the following eregi to check for a valid email
> address:
>
> if (!eregi("^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,4}$", $email)) {
> print_error("your <b>email address</b> is invalid");
> }
>
> While this works fine on most email addresses, it will not allow anyone
> who has more than one dot in their domain name (like me@myisp.co.uk) to
> submit. How can I change this to allow multiple dots in the domain?[/color]

As your expression seems rather incomplete,

Have a look at http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html


--
verum ipsum factum
  #4  
Old July 17th, 2005, 01:36 AM
JDJones
Guest
 
Posts: n/a
Default Re: Email validation with multiple dots in domain name

Justin Koivisto wrote:[color=blue]
> JDJones wrote:
>[color=green]
>>
>> if (!eregi("^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,4}$",
>> $email)) {
>> print_error("your <b>email address</b> is invalid");
>> }
>>
>> While this works fine on most email addresses, it will not allow
>> anyone who has more than one dot in their domain name (like
>> me@myisp.co.uk) to submit. How can I change this to allow multiple
>> dots in the domain?[/color]
>
>
> eregi("^[_\.0-9a-z-]+@([0-9a-z][0-9a-z.-]+\.)+[a-z]{2,4}$", $email)[/color]

Thank you, Justin. I appreciate the help. Amazing what adding a dot in
the right place can do, huh? :)

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.