Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    May 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    change font size of #s in address

    I operate as a admin a online print site where clients can enter in contact info to create imprint on promotional items.

    I create pdf templates with field placeholders |1.1|[address]

    This template is uploaded to the print site which interprets the tags and makes them into variable fields for clients to enter in their info. The site can pull the font name, size, position, etc... from the pdf template.

    For each info field that the site creates it also has an option to apply javascript to that field. So if the template predefines font size X, I just want to apply code that will affect only the numbers of that text and make the numbers a larger font size than the letters.

    The code I'm use to writing is pretty simple stuff for example to format dots instead of dashes for phone numbers like:
    Code:
    if (hasValue(curInput.name))
    {
    if (! AutoFormat(curInput, '###.###.####', 'Please enter your number in a 555.555.5555 format'))curInput.focus();
    }
    I've got no clue where to begin to do what I'm asking so a little help would be much appreciated.

    thanks,

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,146
    Thanks
    203
    Thanked 2,547 Times in 2,525 Posts
    Quote Originally Posted by thisanthrope View Post
    So if the template predefines font size X, I just want to apply code that will affect only the numbers of that text and make the numbers a larger font size than the letters.
    AFAIK that is not possible.

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,561
    Thanks
    80
    Thanked 4,492 Times in 4,456 Posts
    It would be easy to *replace* each digit found with the same digit in a different font.

    Is that what you are after???

    Example:
    Code:
    <style>
    span.BIGRED { font-size: large; color: red; }
    </style>
    <script>
    var demo = "My phone number is 800-111-1212 and I am 37 years old."
    
    var reBig = /(\d+)/g
    demo = demo.replace( reBig, "<span class=BIGRED>$1</span>");
    document.write( demo );
    </script>

  • #4
    New to the CF scene
    Join Date
    May 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Old Pedant View Post
    It would be easy to *replace* each digit found with the same digit in a different font.

    Is that what you are after???

    Example:
    Code:
    <style>
    span.BIGRED { font-size: large; color: red; }
    </style>
    <script>
    var demo = "My phone number is 800-111-1212 and I am 37 years old."
    
    var reBig = /(\d+)/g
    demo = demo.replace( reBig, "<span class=BIGRED>$1</span>");
    document.write( demo );
    </script>
    well, not sure but I'll play around with this.

    the reason I was needing this was that a certain customer uses a specific font. That font's numbers are slightly larger than the letters so when manually typesetting their business collateral, the street address letters are 6pt and the numbers 4.75pt so that they all appear at the same size. PITA

    I've actually already resolved this by just making a custom font by editing the original so all characters are the same size.

    It would have been nice to just plug in some javascript to automate this but problem fixed. Thanks for the help though and I'm sure this bit of code will be useful in other areas!

  • #5
    New to the CF scene
    Join Date
    May 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    <style>
    span.BIGRED { font-size: large; color: red; }
    </style>
    <script>
    var demo = "My phone number is 800-111-1212 and I am 37 years old."
    
    var reBig = /(\d+)/g
    demo = demo.replace( reBig, "<span class=BIGRED>$1</span>");
    document.write( demo );
    </script>
    Hey, this actually does work! not sure yet if I can specify a font point size instead of large, small, etc.... but yeah, this works.


  •  

    Posting Permissions

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