Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > The JavaScript Library

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old June 12th, 2012, 09:17 AM
Gerard Gerard is offline
Junior Community Member
 
Join Date: Feb 2012
Location: Paris
Posts: 24
Default Problem to format phone number

Hi !
I would like to format a French phone number (10 digits) this way: 01 52 93 44 05 (by adding a space every 2 digits).
As I'm totally new to JavaScript, I usually search informations on the forum to edit or modify existing rules to build mines, a way like another to try to understand the "language" but this time, the operation seems to be too complicated for the beginner I am…

I guess I must formulate "for the field "phone", pick the two first digits, then add a space, take the two followers, add another space and so on till digit number 8

Searching in the forum, I tried something like :
return FormatNumber("##&#32##&#32##&#32##&#32##", Field("Tel"));
but it didn't work…

As I don't want you to do the job instead of me, some informations to help me to find my way would be really appreciated !
Thank you !
Gerard.
Reply With Quote
  #2  
Old June 12th, 2012, 09:36 AM
rpaterick rpaterick is offline
Senior Contributor
 
Join Date: Mar 2009
Posts: 427
Default Re: Problem to format phone number

This should work.

Code:
return Str(Field("phone").replace(/(\d{2})(?!$)/g,"$& "));
__________________
Windows 7 64BIT
Intel - I7 chip - 3.33Ghz - 6GB ram
8.0 Creator/8.0 Producer/CS5.5
Reply With Quote
  #3  
Old June 12th, 2012, 11:12 AM
Gerard Gerard is offline
Junior Community Member
 
Join Date: Feb 2012
Location: Paris
Posts: 24
Default Re: Problem to format phone number

Thank you !
It works perfectly, the field filed with or without spaces, exactly what I needed !
Gerard.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 08:43 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2023, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.