Translate

Thursday, March 10, 2011

validate email address

How to validate an email address in asp.net?


To validate an email address in asp.net, use the RegularExpressionValidator. In the validate expression property of the RegularExpressionValidator, select internet email address.

This is how the aspx code would look like

        <asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
        <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
            ErrorMessage="Please enter a valid email address" ControlToValidate="txtEmail"
            ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>






If you are a beginner, look at the screen shots below




















No comments:

Post a Comment

Comments will appear once they have been approved by the moderator