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.

karthik June 26, 2017 at 11:32 PM

wow! what a awesome blog? really your blog was so excellent. the concept of sql server was superb, kindly keep updating because of fresher update.. Nice blog with useful information.. Thanks for sharing. Software Testing Training in Chennai | Six Sigma Certification Training in Chennai | Selenium Training in Chennai

Mounika July 13, 2017 at 6:10 AM

Thank you for sharing good and smart content.keep updating...CCNA Training Institute in Chennai | CCNA Training Institute in Velachery.

PLC Training in Kerala September 7, 2017 at 2:23 AM

Thanks for sharing your informative article..Keep updating such a interesting Blog.

PLC Training in Kerala | PLC Training Institute in Kerala | Inplant Training in Kerala

Post a Comment