Search code examples
asp.netregexemail-validation

Email Regex Validator, not allowing "."


Hey I have the following Regex Validator

<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="email"
                ErrorMessage="Email requires a vaild email address" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*">*</asp:RegularExpressionValidator>

But its not allowing the follow mail [email protected] , I believe the issue is with the . before the @ symbol, but not sure how to update the regex to reflect this


Solution

  • Use this:

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

    This is the default regular expression provided with RegularExpressionValidator. Yours expression have a ' after 8th char. It seems to be invalid.