Link to home
Start Free TrialLog in
Avatar of ITsolutionWizard
ITsolutionWizardFlag for United States of America

asked on

asp.net control validation email

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>
Avatar of David Favor
David Favor
Flag of United States of America image

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.
Avatar of ITsolutionWizard

ASKER

I guess how to create ValidationExpression to accept -- and @ will be helpful.
ASKER CERTIFIED SOLUTION
Avatar of ITsolutionWizard
ITsolutionWizard
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial