1. Home
  2. Computing & Technology
  3. JavaScript

Email Address Validation

5. Multiple Destinations

clr gif

One reader has asked how to have the email validation routine validate more than one email address. I am sure that many others are wondering the same.

Most send mail scripts server side accept a comma separated list of email addresses as the to address in order to send an email to multiple destinations. We can easily adapt the mail script to validate the whole comma separated list by using the following code.

function multiEmail(email_field) {
var email = email_field.split(',');
for (var i = 0; i < email.length; i++) {
if (!validateEmail(email[i], 1, 0)) {
alert('one or more email addresses entered is invalid');
return false;
}
}
return true;
}

The comma separated list of email addresses that is to be validated needs to be passed to the above function which will split it into individual email addresses and validate them.

Explore JavaScript
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. JavaScript

©2009 About.com, a part of The New York Times Company.

All rights reserved.