We help IT Professionals succeed at work.

asp.net control validation email

ITsolutionWizard
on
110 Views
Last Modified: 2019-02-05
I use the following asp net email validator and it works fine until today I get an email (jsmiths@ca--homes.com).
And I want to ensure to accept this string '--'.

how can I do that with my current email validator?


<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
            ControlToValidate="NewEmailAddressTextBox" CssClass="red bold"
            Display="Dynamic" ErrorMessage="*"
            ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
            ValidationGroup="AddNewEmail"></asp:RegularExpressionValidator>
Comment
Watch Question

David FavorFractional CTO
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
Better to do this...

1) Split out user + host parts.

2) Run many regexp patterns against each separately.

Tip: Trying to create a validator with a single regular expression is near impossible to debug or extend.

Author

Commented:
I guess how to create ValidationExpression to accept -- and @ will be helpful.
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION