473,385 Members | 1,930 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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.

Jul 17 '05 #1
3 12656
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: news | last post by:
There's all kinds of ways to validate an email address to make sure it's well formed and whatnot, but what about checking to see if it's a valid e-mail account? Like how you can use checkdnsrr()...
10
by: Chris Sharman | last post by:
I'm doing a rough validation of an email address client-side (using js), but it's not enough - our customer service people are apparently incapable of typing in an email address without error - we...
117
by: Steevo | last post by:
Any suggestions as to the best programs for cloaking email addresses? Many thanks -- Steevo
12
by: Dag Sunde | last post by:
My understanding of regular expressions is rudimentary, at best. I have this RegExp to to a very simple validation of an email-address, but it turns out that it refuses to accept mail-addresses...
4
by: TJS | last post by:
how do I get "onSubmit" to work in .net ? <Form id="Form1" name="Form1" method="post" onSubmit="return validateStandard(this, 'error');" runat="server">
1
by: Manish | last post by:
I want to validate the following emails in the javascript, all emails are valid samples 1. "," comma exists in name 2. Emails can be seperated by comma ",", semicolon ";" 3. Name and email both...
10
by: ll | last post by:
Hi, I currently am using the following regex in js for email validation, in which the email addresses can be separated by commas or semicolons. The problem, however, lies in that I can type two...
2
by: jp2code | last post by:
I've got a couple of strings I use to validate emails. I have no idea what either of them do or what they mean! I found them, they work, so I use them! Could somebody let me know what these...
1
by: saravanatmm | last post by:
I need javascript code for validate the email address. Email address field cannot allowed the capital letters, special characters except '@' symbol. But can allowed the small letters, numeric...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.