By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,984 Members | 1,461 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,984 IT Pros & Developers. It's quick & easy.

Email validation with multiple dots in domain name

P: n/a
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.

Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
JDJones wrote:
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?


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

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

Jul 17 '05 #2

P: n/a
On 2003-12-11, JDJones <se******@sprynet.com> wrote:
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?


As your expression seems rather incomplete,

Have a look at http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html
--
verum ipsum factum
Jul 17 '05 #3

P: n/a
Justin Koivisto wrote:
JDJones wrote:

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?

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


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

Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.