Hi Stephan - thank you so much for your response.

I keep trying, but being unsuccessful.  I tried valid = valid &&,
(valid=valid) &&, and (valid == valid) &&, but I get a syntax error
reference in Firebug. I even tried declaring

 var valid = (value.length > 0); // make sure that value is not empty

outside the for loop with a conditional statement if(valid==true)
inside the for loop, but I am sure I'm doing something wrong.  could
you help again?



jQuery.validator.addMethod("multiemail", function(value, element)
{
if (this.optional(element)) // return true on optional element
                           return true;
                var emails = value.split(',');
                                valid = true;
                         for(var i in emails) {
                                value = emails[i];
                                        valid=valid &&  return 
jQuery.validator.methods.email.call(this,
value, element);
                                }
                }
                        return valid;
                        },
   jQuery.validator.messages.email // use default message
  );

On Mar 2, 2:50 am, Stephan Veigl <stephan.ve...@gmail.com> wrote:
> Hi,
>
> you have the same error as above.
>
> Having a return statement in a for loop will evaluate the first element only.
> If you want to validate all emails that's a logical AND conjunction of
> all single email validations. So you have to have some and function in
> your code as well.
> Try something like:
>
> valid = true;
> for(var i in emails) {
>     value = emails[i];
>     valid = valid && jQuery.validator.methods.email.call(this, value,
> element, param);}
>
> return valid;
>
> by(e)
> Stephan
>
> 2009/3/2 ml2009 <mcl...@systemsview.biz>:
>
>
>
>
>
> > Hello - wonder if you could help me.  I tried another way to validate
> > multiple email addresses, but I still couldn't figure it out. on code
> > below, only the first email is validated.  Any suggestions?
>
> > jQuery.validator.addMethod("multiemail", function(value, element,
> > param) {
> > if (this.optional(element)) // return true on optional element
> >                           return true;
> >                var emails = value.split(',');
>
> >                //      for(var i = 0; i < emails.length; i++) {
> >                 for(var i in emails) {
> >                        value = emails[i];
> >                        //alert(i);
> >                                        return 
> > jQuery.validator.methods.email.call(this, value, element,
> > param);
> >                }
> >        },
> >    jQuery.validator.messages.email // use default message
> >  );- Hide quoted text -
>
> - Show quoted text -

Reply via email to