Search code examples
asp.netajaxregexvalidationemail-validation

How to validate the mail in the server side


How to validate Email in server side . I know how to do that in client side but what about the server side?


Solution

  • You could use a RegularExpressionValidator:

    <asp:RegularExpressionValidator
            id="regEmail"
            ControlToValidate="txtEmail"
            Text="(Invalid email)"
            ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
            Runat="server" /> 
    

    As far as the regular expression to use, just pick one that suits your needs.