In this article I will explain with an example, how to use RegularExpressionValidator in ASP.Net.
HTML Markup
The following HTML Markup consists of a TextBox, an ASP.Net RegularExpressionValidator and a Button control.
The RegularExpressionValidator has been set with a Regular Expression for validating Alphanumeric characters i.e. Alphabets (Upper and Lower case) and Numbers (Digits) in the ValidationExpression property.
The ControlToValidate property has been set with the ID of the TextBox control to be validated.
<asp:TextBox ID="txtAlphaNumeric" runat="server" /><br />
<asp:RegularExpressionValidator ID="rgxAlphaNumeric" runat="server" ValidationExpression="[a-zA-Z0-9]*$"
    ControlToValidate="txtAlphaNumeric" ErrorMessage="*Valid characters: Alphabets and Numbers."
<br /><br />
<asp:Button ID="btnValidate" Text="Validate" runat="server" />
Using RegularExpressionValidator in ASP.Net