Solved

Format phone number

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

911 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