Sunday, June 22, 2014

Regular expression to validate multiple Email IDs separated by comma

Today I am giving you a simple regular expression to validate multiple email IDs separated by comma. This is one of the very common expression we require during the application development.
Regular expression you may use for this purpose is,
Below is the complete code for a sample page to validate multiple Email IDs
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MultipleEmailID.aspx.cs" Inherits="DotnetGalaxy.MultipleEmailID" %>
<!DOCTYPE html>
<html xmlns="">
<head runat="server">
    <form id="form1" runat="server">
        <asp:TextBox ID="txtEmailID" runat="server" Width="400px"></asp:TextBox>
        <asp:Button ID="btnSubmit" runat="server" Text="Submit" />
        <br />
        <asp:RegularExpressionValidator ID="REEmailID" runat="server" ControlToValidate="txtEmailID" ErrorMessage="Please enter valid email addresses separated by commas and in the following format" Font-Bold="True" ForeColor="Red" ValidationExpression="^\s*((\s*[a-zA-Z0-9\._%-]+@[a-zA-Z0-9\.-]+\.[a-zA-Z]{2,4}\s*[,]{1}\s*){1,100}?)?([a-zA-Z0-9\._%-]+@[a-zA-Z0-9\.-]+\.[a-zA-Z]{2,4})\s*$"></asp:RegularExpressionValidator>

And the output will be something like below,
Valid One:
Invalid One:

1 comment:

Payoffers dotin said...

Earn from Ur Website or Blog thr!


Nice to e-meet you. A very warm greetings from PayOffers Publisher Team.

I am Sanaya Publisher Development Manager @ PayOffers Publisher Team.

I would like to introduce you and invite you to our platform, which is one of the fastest growing Indian Publisher Network.

If you're looking for an excellent way to convert your Website / Blog visitors into revenue-generating customers, join the Publisher Network today!

Why to join in Indian Publisher Network?

* Highest payout Indian Lead, Sale, CPA, CPS, CPI Offers.
* Only Publisher Network pays Weekly to Publishers.
* Weekly payments trough Direct Bank Deposit, & Checks.
* Referral payouts.
* Best chance to make extra money from your website.

Join and earn extra money from your Website / Blog

If you have any questions in your mind please let us know and you can connect us on the mentioned email ID

I’m looking forward to helping you generate record-breaking profits!

Thanks for your time, hope to hear from you soon,
The team at