Solved

Format phone number

Posted on 2012-04-02
2
610 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 500 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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
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…

740 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