Phone # formatted textbox

Posted on 2011-10-14
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.
Question by:minglelinch
    LVL 39

    Accepted Solution

    LVL 7

    Expert Comment

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

    Open in new window

    LVL 69

    Expert Comment

    by:Éric Moreau
    LVL 1

    Author Closing Comment

    Thanks for all the comments.  
    The example in emoreau's is execellent.
    I choose ged325's as it is simpler.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
    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…
    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 technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now