Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How To Set Input Mask for Phone Numbers

Status
Not open for further replies.

SGLong

Programmer
Jun 6, 2000
405
US
The Tek-Tips search capability has been down for a long time and I haven't been able to find specific help via the alternate Google Search - probably not using the correct wording.

I'm working on a simple ASP.Net web-site in VB. One of the entry fields is for a phone number. How do I set up an input mask so all the user need do is type the 10 digits (i.e. 8885551212) and the input formats to (888) 555-1212?

Steve
 
if your using ASP.Net 2.0 you can use the MS AJAX Library and AJAX Control Toolkit. they is an input mask control extender. if you not using 2.0 or MS AJAX you could view the javascript associated with this control and try to dissect how it works.

essentially you need to use javascript to validate which keys are pressed when within the control. if the key pressed is valid display the character, if not, abort action.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
I'm using ASP.Net 1.0 so I guess I'll have to go the JavaScript route. As a developer of VB.Net and Visual FoxPro I'm sort of surprised that input masking is not native to ASP.Net.
 
As a developer of VB.Net and Visual FoxPro I'm sort of surprised that input masking is not native to ASP.Net.
The difference there is that both the languages you mention are windows based languages, not web based ones. As you want to validate the client input, you have to use a client side language to do so (i.e. javascript). If you have a look at all server side languages (i.e. ASP.NET, ASP, PHP) none of the server side code will have input masks built into them as it's not the server that needs validating.


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244.
 
Mark,

Thanks for the info. I'm glad you explained it to me.

Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top