Seems a simple regular expression test would work. I've used it for
form validation in the past. Something like this:

emailList = "[EMAIL PROTECTED], [EMAIL PROTECTED],
[EMAIL PROTECTED]";
emailArray = emailList.split(",")
$.each(emailArray, function(index, item){
          item = item.replace(/^\s|\s$/g, '');
          if (item.search(/^([EMAIL PROTECTED],4})$/) == -1){
                     alert("Not a valid e-mail address: "+item);
          }
});

If you aren't familiar w/ regular expressions, there are multiple
references and tutorials online that break them down. Chapter 10 in
David Flanagan's "Javascript: the definitive guide" (the rhino book
(o'reilly)) is pretty good as well.

I've tested the above and it will flag "[EMAIL PROTECTED]"
as an invalid e-mail address. Here's what the code does:
- breaks the comma separated list of addresses into an array of
addresses
- iterates over that array of items
- strips any whitespace from the beginning or end of each address
- searches for valid address constuction
- flags any that aren't properly formatted

The regex can be adapted to fit more specific needs, if you need or
desire.

On Aug 28, 12:37 pm, koolkat <[EMAIL PROTECTED]> wrote:
>  I understand splitting into array, but how do you then call the email
> validate routine on each item in the array?
> Thanks.
>
> On Aug 25, 1:21 pm, "Hasse R. Hansen" <[EMAIL PROTECTED]> wrote:
>
> > I would start with splitting the list of emails, and then loop the
> > array and in every instance of the loop validate the email adress
>
> > /Hasse
>
> > On Aug 25, 9:05 pm,koolkat<[EMAIL PROTECTED]> wrote:
>
> > > Is it possible to use jquery to validate a comma separated list of
> > > emails? If yes, how should this be done?
> > > Thanks

Reply via email to