Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Phone Formatter

Featured Replies

A phone number formatter, that reformats as you type, give it a try (FM 10 only)!

[ This is just a sample, so I'm using American format, I realize not all phone numbers look like this. ]

FM10Test.fp7.zip

  • Author

Here's a much better version, it doesn't show "#" in the field, and allows for a more normal feel (backspacing works now).

It also supports multiple phone patterns, the script currently has three, as you type more digits, it switches to a longer pattern. The three defined now are:

  ###-####

  (###) ###-####

  (###) ###-#### x####

Please give it a try.

PhoneFormat.fp7.zip

  • 4 weeks later...

Thanks. This is a great little script trigger for formatting phone numbers while typing.

I did run into a little snag though. The script has a small bug while entering a digit in the middle of the number (i.e. user mistakenly entered wrong number).

While trying to enter a digit in the middle of the number the cursor is immediately sent to the end of the phone number entry. This is fine if you only needed to enter 1 digit. What if you need to enter more than one digit or delete and replace a digit or 2. Every time you type, the cursor ends up back at the end of the text entry. So you have to take the mouse and click in the middle of the number to finish your correction.

If this bug could be fixed then the script would be perfect.

There is one other thing I would like to mention, this method doesn't work on global unrelated fields. But this is negligible.

Keep up the great work. :)

  • Author

Yeah, I see what you mean.

Try this one, its attempts to fix the selection point to match what it was before it changed the text.

Let me know if you notice any other problems too.

PhoneFormat.fp7.zip

  • 3 weeks later...

Yeah, I see what you mean.

Try this one, its attempts to fix the selection point to match what it was before it changed the text.

Let me know if you notice any other problems too.

I wonder what would be involved in internationalizing this technique? Would this work? If the Country field is other than Canada or the U.S. then require require a country code as well as the region code and the local number.

I realize beyond North America country codes, region codes and even the local number can have variable lengths, making a standard formatting style and validation very difficult.

  • Author

The script has multiple patterns at the top of it that should easily be localizable, you should take a look at it and give it a try.

  • Author

I really like what you've done here. But I confess that I liked the first version which showed (to the User) the masked format they were expected to enter. But I prefer all the enhancements to the second version. I would not dare attempt, nor would I find it respectful, to modify your code not that I could anyway.

Is it possible to have the best of both worlds?

LaRetta, don't be like that, anyone can change it anyway they like, and use it however they want.

Personally, I think the # pattern looks cheesy, but I can see your point about showing the user what's expected.

Here's the modified version, if you decide you don't want to see the patterns after all, change the $showPattern setVariable near the top of the script to False.

PhoneFormat.fp7.zip

Excellent work! With your permission I'd like to take it and apply it to my own database. Yet, I had trouble when I attempted to do so. I used the same script, not modifying anything, right clicked on the field and set it to trigger when modified, with the option script parameter set to:

Get ( ActiveFieldTableName ) & "::" & Get ( ActiveFieldName )

Yet, I get blanks when I try to enter a number in that field. I have attached my sample database and a screenshot. Any help from anyone would be appreciated. Seems like it should work, only difference I noticed was when I set my script trigger, a little red trigger icon appears in my field while it does not in your sample database. Thoughts?

screenshot.jpg

Phone.zip

not really contributing much, but underscore is a good placeholder vs #

  • Author

You didn't copy over the custom function it used, so the script copier in FM helpfully commented out its usage in the script.

You would need to copy the custom function first, then copy the script. I dunno why I'm not seeing the red dot in my field though - I didn't do anything special with that, though I was hooked up to some of the other methods while I was debugging, then took them off.

  • Author

not really contributing much, but underscore is a good placeholder vs #

I was really expecting that to suck also, but it does look nicer. :D

Here's a new copy, with the format character controlled in the script, you need to change the patterns to match it though.

Thanks for the suggestion.

PhoneFormat.fp7.zip

  • 5 months later...
  • Newbies

Love this phonenumber format. But I can't make it work in my file. how do I do it? I have the same problem that when I type in the field, it just shows blank. do I need FMP advanced to get this to work? How do I "copy over the custom function?"

  • Newbies

Hi LaRetta, Just double checking you got the file I emailed you.

Thanks.

  • 7 months later...

Shadow

Thanks for this. Can't get it to work on import. I'm only going to be importing the phone numbers. Am I setting the script triggers wrong?

I'm sure it's been done to death, but I'm guessing FM11 doesn't have phone numbers, etc., as formatting options?

Christopher

  • 3 years later...

Hi,

 

interesting matter, as a friend of mine asked me something similar to do . If this can help, searching the following link should help with worldwide phone number formats - at least with all countries members of ITU..!!.

 

http://www.itu.int/

 

hope this helps. :yep:

 

  • 4 weeks later...

Hi,

To add another dumb question but I am not a programmer, I tried to use these samples onto a Db FMP12, but when I am closing the script window FMP tells me "Function not found" and highlighting " Value:formatCharAs".. I searched but did not find anything corresponding.

 

Any help, ?? What can i use to replace this "formatCharAs" ??

 

Thanks in advance

formatCharAs is a custom function in the demo db.  Since you have Advanced, you can go to File->Manage->Custom Functions... in the demo program and copy and paste it into your database.

 

If you didn't have FMA, you could not use this function, because you need Advanced to edit custom functions. FM can run them once installed by Advanced.

But even without Advanced it can be used as a calculation, no?

Not in this case, because this custom function is recursive (it calls itself). Calculations can't handle that.

OK Guys, 

Thanks a lot, now I am on the custom function case. A part from the FMP help, does it exist anything published about custom functions, I 've a creative mind, but I bet I need to know the rules before letting creativity running loose..!!

Yeaahhhh,

Thanks;

Perfect, let see if I get a brain overheat.. !!!

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.