Solved

Format phone number

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
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…

760 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

20 Experts available now in Live!

Get 1:1 Help Now