Jump 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.

Auto format field for phone number

Featured Replies

  • Newbies

Any suggestions on how to format a field so that the spaces and dashes are automatically entered?

i.e. (800) 123-4567

quote:

Originally posted by gsmith:

Any suggestions on how to format a field so that the spaces and dashes are automatically entered?

i.e. (800) 123-4567

You use two fields. One that the user enters the data into and another that calculates what the displayed phone number should be. Place the two fields exactly on top of each other with the calculated field on top. Set the calculated field to not allow user entry and set the entry field to allow it. This way the calculation field shows up normally, giving you the formatted phone number, but when the user clicks on it, they are put into the actual entry field.

You can probably find a demo file that shows how to do this on the databasepros web site.

Chuck

  • 2 years later...

This works great except in find mode the calculation does not appear. In fact after entering a phone number in find mode the data does not show up unless you are in the field. Any suggestions?

Thanks,

Adrian

Hi Adrian,

You should be doing your finds in the original field, not the calculation field. In fact, the calculation should be locked at the layout level to "Do Not Allow Entry" in the field. If it is, your cursor will go into the original field.

HTH

cool.gif

Lee

Chuck said:

You use two fields. One that the user enters the data into and another that calculates what the displayed phone number should be. (...) You can probably find a demo file that shows how to do this on the databasepros web site.

You can find an example of this in The Works template posted in the Sample Files forum. All the phone number fields, which appear in both Families.fp5 and Persons.fp5, use this technique.

HTH.

Or you can do a search for CobaltSky's indexing unindexable fields trick and use a lookup to overwrite the contents of the original field with the formatted one.

I believe I have set it up properly. I have a text field named phone and a calculation named c_phone. Phone allows entry into the field and is underneath the c_phone field which does not allow entry. Everything formats correctly while in browse mode however, when in find mode after you exit out of the Phone field the data disappears. It is still there when you are inside the field but when you exit the field it disappears. The find performs correctly but it is just an asthetic thing.

Have you guys experienced this problem while using this technique? Maybe I am overlooking something.

The Works file does the same thing in Find mode. See for yourself.

Hi Adrian,

Everything formats correctly while in browse mode however, when in find mode after you exit out of the Phone field the data disappears.

Calculations are no different than text. They all disappear in find mode. This is normal behaviour. smile.gif

LaRetta

LaRetta, took me a while to understand what he was talking about also!

Click on a phone number field in find mode, fill in something, then tab to the next field... unlike normal text fields, the find criteria vanishes! Ick.

I've never noticed that before as normally when I am finding a phone number, that is all the find criteria that I need to enter... so, I never tab to another field.

Anyway, this does need fixing... and here is my thought on the best fix...

First, we need to make the fill of the calculation field transparent. That way, it doesn't cover up the entry field in Find mode.

Then, add a third field, over the entry field but under the calculation field. Make that field also transparent, but have it display a calculation that is a container that holds a blank white graphic (so that it covers up the entry field in browse mode). The calculated graphic will vanish in find mode, leaving two transparent fields showing through the entry field.

Kind of icky, but that should give the desired behavior.

Any better ideas? I need to go implement that in the next version of The Works and in my two databases being built on The Works.

Thanks for pointing that out!

Just answered in his other querry.

Dynamic Input Mask at http://www.fmfiles.com.

The criteria is saved. But it's a bit more compicated than the single overlapping calculation tip.

Though, if you're storing multiple "countries" phone numbers, you should consider it.

Ugo, stop teasing us! That link goes nowhere... and going to fmfiles.com and doing searches on either "dynamic input mask" or "smith" yields nothing.

So, what was the answer?

That Dynamic Input Mask tip has the same ugly bug that in find mode, the field entry vanishes!

So, does anybody have a better suggestion for the phone number field than adding a third stacked field, a transparent one containing a graphic as a background for the field with the formatted phone number???

Otherwise, I'll work on implementing that later this week.

To elaborate on my previous suggestion...

Create a Modification Time field. Create a calcuation of: Right( Mod Time * 0, 0 ) & serial. Create a relationship from this calcuation to the serial number. Make the phone number a lookup based on this relationship, with the calculated 'mask' for the phone number as the looked up field.

When you change the phone number, it will automatically overwrite itself with the mask. Now you've no need for stacked or transparent fields.

Well, yes sorry Brian,

I thought you were saying that when tabbing out of the field, the found criteria was "deleted", while it just "disappear".

So yes, both solutions have the same behaviour. I should have tested your Works before, or should have thought of it, as there was no reason the find criteria would ever be deleted by a tab out of field.

Never mind, just a layout tip then. Ciao.

Create an account or sign in to comment

Important Information

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

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.