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

Email Validation for multiple emails (comma separated)

P: n/a
ll
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 emails
(as a run-on, with no comma or semicolon), and as long as it ends in a
three character domain, it is accepted as valid.

I wonder if there would be a way to make the comma or semicolon
mandatory if a second email address existed?
Many thanks for any help - Louis

Here is the script:

function checkEmailForErrors (Form,Field) {
var emailFilter2=/(([a-zA-Z0-9\-?\.?]+)@(([a-zA-Z0-9\-_]+\.)+)([a-z]
{2,3})(\W?[,;]\W?(?!$))?)+$/i;
var emailValue2=eval("document."+Form+"."+Field+".valu e");
if (!(emailFilter2.test(emailValue2))) {
return false;
}else{
return true;
}
}

May 30 '07 #1
Share this Question
Share on Google+
10 Replies


P: n/a
You can try to use the following regular expression:
/^[A-Z0-9\._%-]+@[A-Z0-9\.-]+\.[A-Z]{2,4}(?:(?:[,;][A-Z0-9\._%-]+@[A-
Z0-9\.-]+))?$/i
I not tested it but hope to work good for you.
P.P:
Sorry for my bad english.
Good Luck !
ll :
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 emails
(as a run-on, with no comma or semicolon), and as long as it ends in a
three character domain, it is accepted as valid.

I wonder if there would be a way to make the comma or semicolon
mandatory if a second email address existed?
Many thanks for any help - Louis

Here is the script:

function checkEmailForErrors (Form,Field) {
var emailFilter2=/(([a-zA-Z0-9\-?\.?]+)@(([a-zA-Z0-9\-_]+\.)+)([a-z]
{2,3})(\W?[,;]\W?(?!$))?)+$/i;
var emailValue2=eval("document."+Form+"."+Field+".valu e");
if (!(emailFilter2.test(emailValue2))) {
return false;
}else{
return true;
}
}
May 30 '07 #2

P: n/a
ll
On May 30, 3:04 pm, Georgi Naumov <gonau...@gmail.comwrote:
You can try to use the following regular expression:
/^[A-Z0-9\._%-]+@[A-Z0-9\.-]+\.[A-Z]{2,4}(?:(?:[,;][A-Z0-9\._%-]+@[A-
Z0-9\.-]+))?$/i
I not tested it but hope to work good for you.
P.P:
Sorry for my bad english.
Good Luck !
ll :
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 emails
(as a run-on, with no comma or semicolon), and as long as it ends in a
three character domain, it is accepted as valid.
I wonder if there would be a way to make the comma or semicolon
mandatory if a second email address existed?
Many thanks for any help - Louis
Here is the script:
function checkEmailForErrors (Form,Field) {
var emailFilter2=/(([a-zA-Z0-9\-?\.?]+)@(([a-zA-Z0-9\-_]+\.)+)([a-z]
{2,3})(\W?[,;]\W?(?!$))?)+$/i;
var emailValue2=eval("document."+Form+"."+Field+".valu e");
if (!(emailFilter2.test(emailValue2))) {
return false;
}else{
return true;
}
}

Thanks very much for this - I am experimenting with it and will keep
you posted!
Regards,
Louis

May 31 '07 #3

P: n/a
ll
On May 31, 4:28 pm, ll <barn104_1...@yahoo.comwrote:
On May 30, 3:04 pm, Georgi Naumov <gonau...@gmail.comwrote:
You can try to use the following regular expression:
/^[A-Z0-9\._%-]+@[A-Z0-9\.-]+\.[A-Z]{2,4}(?:(?:[,;][A-Z0-9\._%-]+@[A-
Z0-9\.-]+))?$/i
I not tested it but hope to work good for you.
P.P:
Sorry for my bad english.
Good Luck !
ll :
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 emails
(as a run-on, with no comma or semicolon), and as long as it ends in a
three character domain, it is accepted as valid.
I wonder if there would be a way to make the comma or semicolon
mandatory if a second email address existed?
Many thanks for any help - Louis
Here is the script:
function checkEmailForErrors (Form,Field) {
var emailFilter2=/(([a-zA-Z0-9\-?\.?]+)@(([a-zA-Z0-9\-_]+\.)+)([a-z]
{2,3})(\W?[,;]\W?(?!$))?)+$/i;
var emailValue2=eval("document."+Form+"."+Field+".valu e");
if (!(emailFilter2.test(emailValue2))) {
return false;
}else{
return true;
}
}

Thanks very much for this - I am experimenting with it and will keep
you posted!
Regards,
Louis


I've tested this, and currently, if I enter more than two email
addresses with the following code, I get the validation error. I
would like to be able to enter as many email addresses as I would like
- how would this be possible? Thanks
Code below:
----
var emailFilter2=/^[A-Z0-9\._%-]+@[A-Z0-9\.-]+\.[A-Z]{2,4}(?:(?:[,;][A-
Z0-9\._%-]+@[A-Z0-9\.-]+))?$/i

May 31 '07 #4

P: n/a
Yes.
This is possible. Try pattern in this way:
var emailFilter2=/^[A-Z0-9\._%-]+@[A-Z0-9\.-]+\.[A-Z]{2,4}(?:[,;][A-
Z0-9\._%-]+@[A-Z0-9\.-]+\.[A-Z]{2,4})*$/i;
Tell me if it working properly.

Best regards.
ll :
On May 31, 4:28 pm, ll <barn104_1...@yahoo.comwrote:
On May 30, 3:04 pm, Georgi Naumov <gonau...@gmail.comwrote:
You can try to use the following regular expression:
/^[A-Z0-9\._%-]+@[A-Z0-9\.-]+\.[A-Z]{2,4}(?:(?:[,;][A-Z0-9\._%-]+@[A-
Z0-9\.-]+))?$/i
I not tested it but hope to work good for you.
P.P:
Sorry for my bad english.
Good Luck !
ll :
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 emails
(as a run-on, with no comma or semicolon), and as long as it ends in a
three character domain, it is accepted as valid.
I wonder if there would be a way to make the comma or semicolon
mandatory if a second email address existed?
Many thanks for any help - Louis
Here is the script:
function checkEmailForErrors (Form,Field) {
var emailFilter2=/(([a-zA-Z0-9\-?\.?]+)@(([a-zA-Z0-9\-_]+\.)+)([a-z]
{2,3})(\W?[,;]\W?(?!$))?)+$/i;
var emailValue2=eval("document."+Form+"."+Field+".valu e");
if (!(emailFilter2.test(emailValue2))) {
return false;
}else{
return true;
}
}
Thanks very much for this - I am experimenting with it and will keep
you posted!
Regards,
Louis

I've tested this, and currently, if I enter more than two email
addresses with the following code, I get the validation error. I
would like to be able to enter as many email addresses as I would like
- how would this be possible? Thanks
Code below:
----
var emailFilter2=/^[A-Z0-9\._%-]+@[A-Z0-9\.-]+\.[A-Z]{2,4}(?:(?:[,;][A-
Z0-9\._%-]+@[A-Z0-9\.-]+))?$/i
Jun 1 '07 #5

P: n/a
ll
On Jun 1, 3:01 am, Georgi Naumov <gonau...@gmail.comwrote:
Yes.
This is possible. Try pattern in this way:
var emailFilter2=/^[A-Z0-9\._%-]+@[A-Z0-9\.-]+\.[A-Z]{2,4}(?:[,;][A-
Z0-9\._%-]+@[A-Z0-9\.-]+\.[A-Z]{2,4})*$/i;
Tell me if it working properly.

Best regards.
ll :
On May 31, 4:28 pm, ll <barn104_1...@yahoo.comwrote:
On May 30, 3:04 pm, Georgi Naumov <gonau...@gmail.comwrote:
You can try to use the following regular expression:
/^[A-Z0-9\._%-]+@[A-Z0-9\.-]+\.[A-Z]{2,4}(?:(?:[,;][A-Z0-9\._%-]+@[A-
Z0-9\.-]+))?$/i
I not tested it but hope to work good for you.
P.P:
Sorry for my bad english.
Good Luck !
ll :
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 emails
(as a run-on, with no comma or semicolon), and as long as it ends in a
three character domain, it is accepted as valid.
I wonder if there would be a way to make the comma or semicolon
mandatory if a second email address existed?
Many thanks for any help - Louis
Here is the script:
function checkEmailForErrors (Form,Field) {
var emailFilter2=/(([a-zA-Z0-9\-?\.?]+)@(([a-zA-Z0-9\-_]+\.)+)([a-z]
{2,3})(\W?[,;]\W?(?!$))?)+$/i;
var emailValue2=eval("document."+Form+"."+Field+".valu e");
if (!(emailFilter2.test(emailValue2))) {
return false;
}else{
return true;
}
}
Thanks very much for this - I am experimenting with it and will keep
you posted!
Regards,
Louis
I've tested this, and currently, if I enter more than two email
addresses with the following code, I get the validation error. I
would like to be able to enter as many email addresses as I would like
- how would this be possible? Thanks
Code below:
----
var emailFilter2=/^[A-Z0-9\._%-]+@[A-Z0-9\.-]+\.[A-Z]{2,4}(?:(?:[,;][A-
Z0-9\._%-]+@[A-Z0-9\.-]+))?$/i
Georgi,
Many thanks - this is working very well. I noticed that you removed
the extra "(?:". What did this help to do?
Many thanks,
Louis

Jun 1 '07 #6

P: n/a
In comp.lang.javascript message <11**********************@q69g2000hsb.go
oglegroups.com>, Fri, 1 Jun 2007 01:01:28, Georgi Naumov
<go******@gmail.composted:
>This is possible. Try pattern in this way:
var emailFilter2=/^[A-Z0-9\._%-]+@[A-Z0-9\.-]+\.[A-Z]{2,4}(?:[,;][A-
Z0-9\._%-]+@[A-Z0-9\.-]+\.[A-Z]{2,4})*$/i;
(A) That rejects at least 2 classes of valid E-mail address. Don't
present E-mail validators unless you are sure that they will accept
anything RFC-compliant.

(B) Your RegExp contains repetition. IMHO, it would be better to split
the string on the set of possible separators and check each part
separately; YMMV. That should help more friendly error reporting, too.

See <URL:http://www.merlyn.demon.co.uk/js-valid.htm>.

<FAQENTRYE-mail checking is a FAQ.
The most cost-effective answer is "Don't" but a little expansion would
be OK.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk DOS 3.3, 6.20 ; WinXP.
Web <URL:http://www.merlyn.demon.co.uk/- FAQqish topics, acronyms & links.
PAS EXE TXT ZIP via <URL:http://www.merlyn.demon.co.uk/programs/00index.htm>
My DOS <URL:http://www.merlyn.demon.co.uk/batfiles.htm- also batprogs.htm.
Jun 2 '07 #7

P: n/a
(A) That rejects at least 2 classes of valid E-mail address. Don't
present E-mail validators unless you are sure that they will accept
anything RFC-compliant.
When we made regular expression to respect RFC 822 standart regular
expression
become 6343 characters long. Using this regular expression in actual
applications is
not recommended.
>
(B) Your RegExp contains repetition. IMHO, it would be better to split
the string on the set of possible separators and check each part
separately; YMMV. That should help more friendly error reporting, too.
May be you are right. May be we can check the differences between
performances
in this two cases.
Here is the RFC compliliant regular expression:
################################################## ############################
(?:(?:\r\n)?[ \t])*(?:(?:(?:[^()<>@,;:\\".\[\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?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\]
\x00-\x1F]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\
[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*)*:(?:(?:\r\n)?[ \t])*)?(?:
[^()<>@,;:\\".\[\] \x00-\x1F]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:
\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)
(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \x00-\x1F]+(?:(?:(?:\r
\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r
\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\
\".\[\] \x00-\x1F]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\
[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?
[ \t])*(?:[^()<>@,;:\\".\[\] \x00-\x1F]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\
["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*\>(?:
(?:\r\n)?[ \t])*))*)?;\s*)
################################################## ############################

Dr J R Stockton :
In comp.lang.javascript message <11**********************@q69g2000hsb.go
oglegroups.com>, Fri, 1 Jun 2007 01:01:28, Georgi Naumov
<go******@gmail.composted:
This is possible. Try pattern in this way:
var emailFilter2=/^[A-Z0-9\._%-]+@[A-Z0-9\.-]+\.[A-Z]{2,4}(?:[,;][A-
Z0-9\._%-]+@[A-Z0-9\.-]+\.[A-Z]{2,4})*$/i;

(A) That rejects at least 2 classes of valid E-mail address. Don't
present E-mail validators unless you are sure that they will accept
anything RFC-compliant.

(B) Your RegExp contains repetition. IMHO, it would be better to split
the string on the set of possible separators and check each part
separately; YMMV. That should help more friendly error reporting, too.

See <URL:http://www.merlyn.demon.co.uk/js-valid.htm>.

<FAQENTRYE-mail checking is a FAQ.
The most cost-effective answer is "Don't" but a little expansion would
be OK.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk DOS 3.3, 6.20 ; WinXP.
Web <URL:http://www.merlyn.demon.co.uk/- FAQqish topics, acronyms & links.
PAS EXE TXT ZIP via <URL:http://www.merlyn.demon.co.uk/programs/00index.htm>
My DOS <URL:http://www.merlyn.demon.co.uk/batfiles.htm- also batprogs.htm.
Jun 2 '07 #8

P: n/a
Georgi Naumov wrote:
>(A) That rejects at least 2 classes of valid E-mail address. Don't
present E-mail validators unless you are sure that they will accept
anything RFC-compliant.
When we made regular expression to respect RFC 822 standart regular
expression
become 6343 characters long. Using this regular expression in actual
applications is
not recommended.
>(B) Your RegExp contains repetition. IMHO, it would be better to split
the string on the set of possible separators and check each part
separately; YMMV. That should help more friendly error reporting, too.
May be you are right. May be we can check the differences between
performances
in this two cases.
Here is the RFC compliliant regular expression:
<snip regular expression>

I get 6,341 characters when I strip 92 newlines. Are you sure 6,343 is
accurate?

--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
Jun 2 '07 #9

P: n/a
In comp.lang.javascript message <11**********************@w5g2000hsg.goo
glegroups.com>, Sat, 2 Jun 2007 12:15:02, Georgi Naumov
<go******@gmail.composted:
>(A) That rejects at least 2 classes of valid E-mail address. Don't
present E-mail validators unless you are sure that they will accept
anything RFC-compliant.
When we made regular expression to respect RFC 822 standart regular
expression
become 6343 characters long. Using this regular expression in actual
applications is
not recommended.
There must be better ways of checking for RFC compliance than with a
single RegExp.

Although all working E-mail addresses should be RFC compliant, one
cannot be certain that all actually are. So checking for strict
compliance risks rejecting one that would work.

Checking format cannot indicate whether an E-address is currently
deliverable in the sense that all the software considers it deliverable;
and even if it is in that sense delivered there can be no guarantee that
it is an address that gets read.

The only worthwhile check, IMHO, is whether the string might be an E-
address, rather than empty or something that's been put into the wrong
field. For that, a test for <something>@<something>.<somethingwill do
- though the form "Fred Q. Smith" <... should be accepted.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/- FAQqish topics, acronyms & links;
Astro stuff via astron-1.htm, gravity0.htm ; quotings.htm, pascal.htm, etc.
No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.
Jun 3 '07 #10

P: n/a
ll
On Jun 3, 10:47 am, Dr J R Stockton <j...@merlyn.demon.co.ukwrote:
In comp.lang.javascript message <1180811702.952902.154...@w5g2000hsg.goo
glegroups.com>, Sat, 2 Jun 2007 12:15:02, Georgi Naumov
<gonau...@gmail.composted:
(A) That rejects at least 2 classes of valid E-mail address. Don't
present E-mail validators unless you are sure that they will accept
anything RFC-compliant.
When we made regular expression to respect RFC 822 standart regular
expression
become 6343 characters long. Using this regular expression in actual
applications is
not recommended.

There must be better ways of checking for RFC compliance than with a
single RegExp.

Although all working E-mail addresses should be RFC compliant, one
cannot be certain that all actually are. So checking for strict
compliance risks rejecting one that would work.

Checking format cannot indicate whether an E-address is currently
deliverable in the sense that all the software considers it deliverable;
and even if it is in that sense delivered there can be no guarantee that
it is an address that gets read.

The only worthwhile check, IMHO, is whether the string might be an E-
address, rather than empty or something that's been put into the wrong
field. For that, a test for <something>@<something>.<somethingwill do
- though the form "Fred Q. Smith" <... should be accepted.

--
(c) John Stockton, Surrey, UK. ?...@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/- FAQqish topics, acronyms & links;
Astro stuff via astron-1.htm, gravity0.htm ; quotings.htm, pascal.htm, etc.
No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.


Thanks everyone,
Appreciate your help in this.
Kind regards,
Louis

Jun 4 '07 #11

This discussion thread is closed

Replies have been disabled for this discussion.