Email Address Validation5. Multiple Destinations |
|
Join the DiscussionMore of this FeatureIntroduction Obtain the Script Add to Your Page Spanish Version 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. |

