Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

This topic is 7365 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies
Posted

I am having trouble formatting a phone number field to display the phone number as (000)000-0000, I would also like an error message to display if an incorrect number of digits are entered. Wasn't sure to do it as calculation or number field, etc cannot find options nor sure of the code to format it this way.

Any help would be greatly appreciated!! it is currently defined as a number field.

Posted

The phone number should be a text field. It is not a number, i.e., 5*Phone Number + 3 does not have any meaning.

In pre FMP7 a calculated text field was placed on top of the entry field. The calculated field would then show the formatted phone number. you might try a calculation like this:

Phone = Subsitute (Subsitute (Subsitute (Subsitute( "-", "")), "(", ""), ")", ""), "(", "")

Case ( Lenght (Phone) <> 10, "Enter 10 digit phone number",

"(" & Left ( Phone, 3) & ") " & Middle (Phone, 4, 3) & "-" & Middle (Phone, 7, 4))

Posted

You could also use a trigger field of Left( GetField("Phone Number"), 0 ) & serial, and a self-relationship from trigger to serial, then make the Phone Number a lookup to the calculation field, based on the self-relationship. This would overwrite the entered number with the formatted one without requiring field stacking to create the mask.

A little tweak to Ralph's calc, adding the substitution for a space and fixing a couple of typos:

Case( Length(Substitute( Substitute( Substitute( Substitute( Substitute( phone, "-", "" ), " ", "" ), "(", "" ), ")", "" ), "(", "" )) <> 10, "Enter 10 digit phone number",

"(" & Left( Substitute( Substitute( Substitute( Substitute( Substitute( phone, "-", "" ), " ", "" ), "(", "" ), ")", "" ), "(", "" ), 3 ) & ") " & Middle( Substitute( Substitute( Substitute( Substitute( Substitute( phone, "-", "" ), " ", "" ), "(", "" ), ")", "" ), "(", "" ), 4, 3 ) & "-" & Middle( Substitute( Substitute( Substitute( Substitute( Substitute( phone, "-", "" ), " ", "" ), "(", "" ), ")", "" ), "(", "" ), 7, 4 ) )

This topic is 7365 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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