Validating multiple email addresses

For example, [email protected] is a valid email address.

In short, to validate email addresses, consider going with an established third party library, unless you are dealing with a limited special case.

Though I would go with this method to keep the semantics as you said, and simply use validation on the server side as well just in case someone tries to submit an email like "[email protected]".

Just as a note, you should always validate on the server side for security reasons anyway, as client side validation can be bypassed very easily.

Writing one huge regexp is going to be very difficult and a maintenance nightmare, I suspect.

@Se To Y, if you have particular restrictions - you should state them in your question.

Important note: as states in the comment by Martin, if there are additional text before or after the correct email address list, the validation will not fail. To make it work as a validator you need to add No, it doesn't requiere a semicolon at the end at all!

The last group (\s*;\s*|\s*$), accepts two possibilities: 1) \s*;\s*, whis is a semicolon with optional spaces before or after it, and 2) \s*$ which is the end of the line with optional spaces before it. Here is a slightly modified version that will provide a single capture group matching the full match.

Now you can ask questions directly to me on my new site ASPForums.

For each email address you get a detailed validation result with the exact deliverability status.

With our real-time online API you can validate email addresses right at the point of entry.

This is your original expression, changed so that it allows several emails separated by semicolon and (optionally) spaces besides the semicolon.

It also allows a single email address that doesn't end in semicolon. You can change the final * by to require at least one address.

Search for validating multiple email addresses:

validating multiple email addresses-48validating multiple email addresses-77

If I can't get the built in validation to work, I'll be looking to do it in JS instead so I can give specific helpful messages.

Leave a Reply

Your email address will not be published. Required fields are marked *

One thought on “validating multiple email addresses”