Powered by Blogger.

Sunday, May 18, 2014

RegularExpression Validator example in Asp.Net

In this post we will discuss one example of RegularExpression validator. Also you can check out some articles on:

- Anonymous Types in C#.Net

- Sealed class and Sealed method in C#.Net

- Regular expression validator for image files in Asp.Net

Recently I came accross a situation where I need a validation like below. A field can contain only interger ot 5 or 8 digit. Means it should through validation message of user enters number of length 7 digit, 6 digit, 4 digit etc.

But If you want to validate only numeric values, then you can follow this article.

Below is the code:

<asp:TextBox runat="server" ID="txtNumber" />
        <asp:RegularExpressionValidator runat="server" ID="rexNumber" ControlToValidate="txtNumber"
            ValidationExpression="^[0-9]{5}$|^[0-9]{8}$" ErrorMessage="Please enter a 5 or 8 digit number!"
            ForeColor="Red" />

It will appear like below:


jhansi joe January 5, 2017 at 5:10 AM

Informative post, Thanks for sharing :-)
DOT NET Training in Chennai

Amirtha rao January 8, 2017 at 4:00 AM

Exactly, if you learn any one of the programming language, which they have mentioned above is really helpful to get great career in IT web development industry.
PHP Training in Chennai|PHP Course in Chennai

Rasool Bevi March 19, 2017 at 5:12 AM

Thanks for sharing informative article on java application development. Your post helped to understand the career in Java. JAVA Training in Chennai

deepti March 22, 2017 at 6:35 AM

I have read your blog its very attractive and impressive. Thank you for sharing...
Web Designing Training Institute in Chennai | Web Designing Training in Chennai | No.1 Web Designing Training Institute in Chennai

Amirtha rao May 6, 2017 at 6:23 AM

For management and troubleshooting of enormous databases, corporation’s square measure searching for qualified and licensed dispersions Hadoop experts for the duty. Hadoop Training in Chennai | Hadoop Training Chennai

victoriya May 29, 2017 at 6:41 AM

Wonderful blog. keep sharing.. Android Training Institute in Chennai | Android Training Institute in Velachery.

Post a Comment