RegularExpressionValidator in ASP.NET

The RegularExpressionValidator control performs its validation according to the regular expression. You can check the predefined pattern, such as a phone number, postal code, e-mail address, dates, and so on. The control uses the ValidationExpression property to set a valid regular expression that is applied to the input data.

Example

<asp:TextBox ID="txtEmailID"
        runat="server"
        Width="200px">
</asp:TextBox>      
<asp:RegularExpressionValidator ID="RegularExpressionValidator1"
        runat="server"
        ForeColor="Red"
        ControlToValidate="txtEmailID"
        ErrorMessage="Enter correct EmailID"
        ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*">
</asp:RegularExpressionValidator>