Solved

Format phone number

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

Is Your DevOps Pipeline Leaking?

Is your CI/CD pipeline a hodge-podge of randomly connected tools? You’ve likely got a tool to fix one problem & then a different tool to fix another, resulting in a cluster of tools with overlapping functionality. Learn how to optimize your pipeline with Gartner's recommendations

Question has a verified solution.

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

Suggested Solutions

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article discusses how to create an extensible mechanism for linked drop downs.
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…

734 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