?
Solved

Phone # formatted textbox

Posted on 2011-10-14
4
Medium Priority
?
394 Views
Last Modified: 2012-05-12
I want to have a phone number textbox with a mask with format like xxx-xxx-xxxx, so that no matter what user types it always have the standard format. I like the mask do the job instead my javascript function check the format. How can I do it? Thanks.
0
Comment
Question by:minglelinch
4 Comments
 
LVL 41

Accepted Solution

by:
Kyle Abrahams earned 2000 total points
ID: 36970927
0
 
LVL 7

Expert Comment

by:Bill Nolan
ID: 36970937
You can use a regular expression validator in .net.  Here's an example:
<asp:RegularExpressionValidator ID="ValidatorRegEx_Phone" runat="server"
                    ValidationGroup="SomeGroup"
                    ControlToValidate="TextBox_Phone"
                    ValidationExpression="((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}"
                    Text="Invalid telephone number!">
                </asp:RegularExpressionValidator>

Open in new window

0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 36971763
0
 
LVL 1

Author Closing Comment

by:minglelinch
ID: 36972017
Thanks for all the comments.  
The example in emoreau's is execellent.
I choose ged325's as it is simpler.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question