Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RegularExpressionValidator for multiple emails

I'm validating a textbox for valid email with this:

<asp:RegularExpressionValidator ID="RegularExpressionValidator1"
ControlToValidate="txtMailCustom"
Text="Invalid address"
ValidationExpression="^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]
{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$" runat="server" />  

Now I want users to be able to put multiple email addresses , separated by a comma and space.

How can I integrate that behaviour ?


1 Answers

Try the expression below, which works for me:

((\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*)*([,])*)*

The above code is for ,, separating e-mail addresses.

If you would like to use ; instead of ,, than replace , with ; at the end of the above expression.

like image 182
Sachin Kalia Avatar answered Jan 22 '26 00:01

Sachin Kalia



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!