?
Solved

Format phone number

Posted on 2012-04-02
2
Medium Priority
?
626 Views
Last Modified: 2012-04-24
Hi,

I am building an application using MVC3
when the user trying to edit the phone number I want them to get this format displayed ( ) -

if the passed phone number has 7 numbers or more I need to display that number in
this format
(000) 000-0000

ortherwise just output it the way it is.

this is code that display the phone number:

    @Html.TextBoxFor(m => m.Customer.PhoneNumber1, new { @class = "textBox" })

how can I say if the customer.PhoneNumber1 has more than 7 numbers to format my field?
0
Comment
Question by:lulu50
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 14

Accepted Solution

by:
binaryevo earned 2000 total points
ID: 37796140
var textBoxLength = $("#PhoneNumber1").val().length; 
if(textBoxLength > 7){

      //do your display formatting here

     //when your ready, reapply your format to the text here like this
     $("#PhoneNumber1").val("my new formatted value");
    
}

Open in new window

0
 

Author Closing Comment

by:lulu50
ID: 37888742
Thanks
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

762 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