RegularExpressionValidator in Asp.net Text box Control

RegularExpressionValidator in Asp.net Text box Control:



RegularExpressionValidator :

The RegularExpressionValidator is a bit more difficult to write about, because it requires knowledge of Regular Expressions to really use it. However, RegularExpressionValidator is one of the most useful validators, because it can be used to check the validity of any kind of string. If you don't feel like learning Regular Expressions, but still feel like using this validator, have a look around the Internet. 

You can find many pre-made expressions out there, which can be very useful to you. Here is an example where we require a 4 digit number - nothing else is acceptable:

take a asp.net text box control
<asp:TextBox runat="server" id="txtNumber" />
<asp:RegularExpressionValidator runat="server" id="txtvNumber" controltovalidate="txtNumber" validationexpression="^[0-9]{4}$" errormessage="Enter a 4 digit number!" />
<br />

Asp.net Related Other Post:

Comments