Duncan Mackenzie Microsoft Developer Network May 2002 Summary: Covers the basics of inheriting from another control and adding your own properties, methods, and events along with adding your own code; one of a series of Microsoft Windows Forms control development samples to be read in conjunction with associated overview article. This article is the second in a five-article series on developing controls in Microsoft® .
NET: Introduction Sample 1a: Adding Regular Expression Validation to the Text Box Control A Short Discussion on Regular Expressions What Do I Need to Build?
If all the formats don't fit your demand, please describe explicitly what is the format of the phone number that you want.
For example, is you want it to be like this: 010-87358217 or simplely 87358217, then you should set the Validate Expression like this: (\d-)? This will match all the xxx-xxxxxxxx or xxxxxxxx like input digital numbers.
Hi sammus, Based on my understanding, you wana validate if the Phone Number. There is a Regular Expression Validator in the Visual Web Developer. Just don't forget to set the "Ctrol To Validate" property and select Validate Expression in the property window.
It has some formats of phone numbers of various countrys already.
In the overview article, I showed you how to quickly enhance the Text Box control to accept only numeric data, creating a new control with a minimum amount of work on your part.Instead of simply expanding this control to support currency and other numerical formats, a better approach is to create a more generic control to restrict text entry. NET (Web) applications, a control has already been provided to accomplish exactly what I am describing: the Regular Expression Validator Control documented in the . This control allows you to restrict text entry to any format that can be described with a regular expression, which essentially means any format at all.Since a version of this control hasn't been provided for use in Windows Forms, it makes a great example of a custom control that you can build—a Windows Form Text Box that validates its contents against a regular expression.This paper introduces these new controls and discusses tips and tricks on working with them in practical scenarios.(34 printed pages) Introduction Looking at Validation The Required Field Validator Control The Compare Validator Control The Range Validator Control The Regular Expression Validator Control The Custom Validator Control The Validation Summary Control Conclusion In your studies of ASP.