Hi,

Taking a second look on your code it's clear why only the first email
address is validated: you have a return statement in your for loop.

try something like:

email: function(value, element) {
  if (this.optional(element)) // return true on optional element
(whatever this is for?)
    return true;
  var emails = value.split(,);
  var valid = (value.length > 0); // make sure that value is not empty
  for(var emailAddress in emails)
  {
    valid = valid && /.../i.test(emailAddress); // logical and of all
email validations
  }
  return valid;
}

by(e)
Stephan

2009/2/17 roryreiff <roryre...@gmail.com>:
>
> Yeah, I actually have that fixed in the posted link, but thanks for
> pointing that out. So, something else is at error now.
>
> On Feb 17, 9:04 am, Stephan Veigl <stephan.ve...@gmail.com> wrote:
>> Hi
>>
>> is this just a copy & paste error, or a real syntax error? You have to
>> quote the comma in your split command:
>>   var emails = value.split(",");
>>
>> by(e)
>> Stephan
>>
>> 2009/2/17roryreiff<roryre...@gmail.com>:
>>
>>
>>
>> > So far, I have adapted this:
>>
>> > email: function(value, element) {
>> >                        return this.optional(element) || 
>> > /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?
>> > \^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\
>> > $%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)
>> > *)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c
>> > \x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF
>> > \uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-
>> > \uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?
>> > (\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-
>> > z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|
>> > [\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF
>> > \uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF
>> > \uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-
>> > z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|
>> > [\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test(value);
>> >                },
>>
>> > into this:
>>
>> > email: function(value, element) {
>> >                        var emails = value.split(,);
>> >                        for(var emailAddress in emails)
>> >                        {
>> >                                return this.optional(element) || 
>> > /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?
>> > \^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\
>> > $%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)
>> > *)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c
>> > \x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF
>> > \uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-
>> > \uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?
>> > (\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-
>> > z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|
>> > [\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF
>> > \uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF
>> > \uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-
>> > z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|
>> > [\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test(emailAddress);
>> >                        }
>> >                },
>>
>> > any thoughts why this is not working? Thanks,
>>
>> > On Feb 13, 11:10 am, Ed Lerner <emle...@gmail.com> wrote:
>> >> I'm new to jQuery as well. In other languages, you would take the
>> >> string that holds all of the emails and do a 'split' on commas. This
>> >> should give you an array where each element is an individual email.
>> >> From there, just validate each element.
>> >> How to do this in jQuery, someone more experienced than I may be able
>> >> to help with.
>>
>> >> On Feb 13, 11:28 am,roryreiff<roryre...@gmail.com> wrote:
>>
>> >> > Hi there,
>>
>> >> > I am using the Validation plugin to validate a form that emails the
>> >> > current pages URL to the recipients entered in to the "email to"
>> >> > field. I want to validate that field for multiple emails addressed
>> >> > separated by commas...and ideas on how to do this? I'm a bit new to
>> >> > jQuery so I am a little confused how to approach this. I was thinking
>> >> > somehow altering the email function so that is parses the input and
>> >> > does a for each on every email address. Is this correct thinking? Is
>> >> > there an easier way to do this?
>>
>> >> > Thanks,

Reply via email to