ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Format a telephone number

May 02, 2008 2:55pm

Subscribe [0]
  • #1 / May 02, 2008 2:55pm

    seajay

    109 posts

    What is the best way to get telephone numbers formatted upon entry?

    Is there a telephone custom field extension, as there are for other formatted fields?

    If not, what is EE convention? Multiple fields for each part? (Not very appealing.)

  • #2 / May 02, 2008 4:03pm

    Ingmar

    29245 posts

    seajay, there is no built-in way to validate or otherwise format the data on input. Having said hat, an extension and some javascript should be able to do that, but it’d be a custom soltuion.

  • #3 / May 02, 2008 4:11pm

    seajay

    109 posts

    Thanks. I thought that might be the case, but didn’t find a thread about either of those options, and was hoping ...

    Since I’m not skilled to that degree, I guess you can close this thread. Sigh.

  • #4 / May 02, 2008 8:48pm

    Rob Allen

    3105 posts

    If you use a custom entry field for the telephone number you can style it using CSS.

    Create a custom field, ie {telephone_number}, and set the field formatting to “none”

    Add the tag to your template surrounded by an approriate HTML tag

    {telephone_number}

    Now add a class and a style…

    {telephone_number}
    
    .telephone-number {font-weight: bold; color: #FF9900;}
  • #5 / May 02, 2008 8:51pm

    seajay

    109 posts

    I was thinking about formatting, rather than styling.

    For example, in the Control Panel, I would like to require people to enter as ...

    +x-xxx-xxx-xxxx

    ... where X is a digit. Or, automatically rewriting a number into that format. Or another one.

    But, this is not a showstopper. The thread can be closed.

  • #6 / May 03, 2008 3:30am

    Ingmar

    29245 posts

    Your best bet is javascript. If you’re using the SAEF you could do it that way, if you use the backend, or want to check upon submission you’d need an etxension.

  • #7 / May 03, 2008 6:08am

    Mark Bowen

    12637 posts

    As Ingmar says if you are using the SAEF then you could use some Javascript with it such as this one or this one or this or this or this.

    Don’t know if any of those are any good?

    Best wishes,

    Mark

  • #8 / May 03, 2008 9:10am

    seajay

    109 posts

    Thank you!

  • #9 / May 03, 2008 9:40am

    Mark Bowen

    12637 posts

    No problem. There are some really nifty Javascript solutions going around at the moment for this type of thing.

    Let us know how you get on.

    Best wishes,

    Mark

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases