SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jul 2006
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question help...changing phone# format code

    this function (below) makes a phone number be formatted like so (123) 456-7899. i would like to change it so that it is formatted with a bullet in between each set of numbers instead... 123∙456∙7899 .i guess the symbol is &#183. but i'm not sure of the syntax. any help?

    thanks


    Code:
    var formatStyle01 = "($1) $2-$3";
    
    var formatStyle02 = "$1-$2-";
    
    var theNumber = Field("TopPhone1");
    
     
    
    return formatNumber(theNumber);
    
    function formatNumber(number01){
    
          var pattern01=/^(\d{3})[^\d]+{3})[^\d]+(\d{4})$/;
    
          var pattern02=/^[^\d]+(\d{3})[^\d]+(\d{3})[^\d]+(\d{4})$/;
    
          var pattern03=/^[^\d]+(\d{3})[^\d]+\s+(\d{3})[^\d]+(\d{4})$/;
    
          var pattern04=/^(\d{3})(\d{3})(\d{4})$/;
    
          var pattern05=/^)\d{3})[^\d](\d{4})$/;
    
          var pattern06=/^(\d{3})(\d{4})$/;
    
          if (number01.length == 7){
    
                number01 = number01.replace(patter06, formatStyle02);
    
                return number01;
    
          }else if (number01.length == 8){
    
                number01 = number01.replace(pattern05, formatStyle02);
    
                return number01;
    
          }else if (number01.length == 10){
    
                number01 = number01.replace(pattern04, formatStyle01);
    
                return number01;
    
          }else if (number01.length == 12){
    
                number01 = number01.replace(pattern04, formatStyle01);
    
                return number01;
    
          }else if (number01.length == 13){
    
                number01 = number01.replace(pattern02, formatStyle01);
    
                return number01;
    
          }else if (number01.length == 14){
    
                number01 = number01.replace(pattern03, formatStyle01);
    
                return number01;
    
          }else
    
                return theNumber;
    
    }
    Last edited by stymiee; Jul 13, 2006 at 11:47.

  2. #2
    SitePoint Wizard chris_fuel's Avatar
    Join Date
    May 2006
    Location
    Ventura, CA
    Posts
    2,750
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    What happens if the user has javascript turned off?

  3. #3
    SitePoint Member
    Join Date
    Jul 2006
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi,

    not really worried about that at this point. the javascript is turned on for testing.

    need to change this line:

    var formatStyle01 = "($1) $2-$3";

    so that a bullet shows in place of the -

    ? thanks.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •