| Author |
validate multiple email addresses in a textarea
|
Pravin Jain
Ranch Hand
Joined: May 20, 2007
Posts: 60
|
|
How do I validate multiple email addresses entered in a textarea. one per line in the text area.
|
The Zen of Java Programming.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56151
|
|
|
On the client or server? Do you know how you would validate a single such entry? What code have you written so far?
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Pravin Jain
Ranch Hand
Joined: May 20, 2007
Posts: 60
|
|
Originally posted by Bear Bibeault: On the client or server? Do you know how you would validate a single such entry? What code have you written so far?
The validation is required on the client side using javascript. I have a form with several input fields. one of the fields is for accepting multiple email addresses, one email per line. I need to check that each line contains a valid email address. The field may be left blank, but if there is any entry then it should be a valid email address. I have got a regex pattern which can validate a single entry. The regex is as follows: /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i will it work if I simply group this regex as follows: (/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i)* Thanks Pravin [ October 02, 2007: Message edited by: Pravin Jain ]
|
 |
Dan Drillich
Ranch Hand
Joined: Jul 09, 2001
Posts: 1121
|
|
|
I prefer to create several HTML input fields, so each one can be validated and normalized independently.
|
William Butler Yeats: All life is a preparation for something that probably will never happen. Unless you make it happen.
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16479
|
|
|
Or better still, don't validate e-mail addresses at all.
|
 |
Valentin Crettaz
Gold Digger
Sheriff
Joined: Aug 26, 2001
Posts: 7610
|
|
will it work if I simply group this regex as follows: (/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i)* Nope, the ()* must be within the regular expression, i.e. within the /.../ Try this
|
SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
|
 |
 |
|
|
subject: validate multiple email addresses in a textarea
|
|
|