Software Venture Consulting

FileMaker Pro downloads & Resources
FileMaker Custom Functions
FileMaker Web Viewer Examples
FileMaker Pro & Lasso Consulting
Training
FileMaker Books
FileMaker Articles
FileMaker Error Reference

Free Web Tools
Free FileMaker Tools

Personal Pages
Videos
Adventures
Links

Shopping Cart
Shopping Cart

Search:

Free Newsletter
Signup


Contact


Privacy Policy



FileMaker is a registered trademark of FileMaker, Inc. in the U.S. and other countries.

 

 FileMaker Pro Custom Functions

List  |  Show Random  |  Upload  |  Add This to Your Site

Mask (input ; template ; placeholder )

Rate this function:  

RatingRatingRatingRatingRating
  Average rating: 3.9  (50 votes)
  Discuss this Custom Function

Geoffrey Gerhard, Creative Solutions Incorporated
http://www.creativesltns.com

Formats a numeric string to match a template supplied as a parameter (i.e. Phone, Social Security, Federal ID formats)

Sample Input:
Mask ( "1234567890" ; "(###) ###-####" ; "#" )

Mask ( "1234567890123" ; "(###) ###-#### x." ; "#" )

Mask ( "333224444" ; "###-##-####" ; "#" )
Sample Output:
(123) 456-7890

(123) 456-7890 x.123

333-22-4444


 Then copy & paste into FileMaker Advanced's Edit Custom Function window.

Click here to copy To Clip Manager if you have myFMbutler's Clip Manager installed

Description:

UPDATED 06/01/2010--see below*

This function takes a string of numeric digits and formats them according to a template string made of non-numeric values (punctuation and/or text) combined with placeholder values to indicate where the numbers will go as they replace the placeholders. This...
Mask ( "1234567890" ; "(###) ###-####" ; "#" )
...returns...
(123) 456-7890

This function is designed to provide visual feedback when the user makes an invalid entry. Too few characters are indicated by BOLD RED placeholder values for every missing number. For example...
Mask ( "1234567" ; "(###) ###-####" ; "#" )
...would return...
(123) 456-7###
...with the three "#" characters in BOLD/RED

It also indicates too many characters when the template's last character is a placeholder. This...
Mask ( "1234567890123" ; "(###) ###-####" ; "#" )
...would return...
(123) 456-7890123
...with "(123) 456-7890" in the field's default text color/style and the characters "123" in BOLD/RED/STRIKE THROUGH, and " !" in the field's default text color/style to indicate that too many digits were entered. Such feedback may be expecially useful for Federal ID or Social Security Numbers.

This CF will add any extra digits to the end of the template when the last character is something other than a placeholder. Adding " x." to the template as follows...
Mask ( "1234567890123" ; "(###) ###-#### x." ; "#" )
...returns...
(123) 456-7890 x.123

Function Usage:
This function IS recursive.
Strip non-numeric characters from whatever string is passed to this function using the Filter() function like this...
Filter ( phoneNumberText ; 9876543210 )

There is a companion CF called "DialByWord" that converts uppercase letters into numbers, while ignoring lower-case letters that converts an entry like 800-CALL ATT to a the corresponding alpha-numeric string.

*Note: Updated one line in the function to account for "." as a separator among the placeholders when the input ends with one or more zeros. Thanks to Matt Lygo for the feedback!

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

This is my Custom Function and I want to edit it

Discuss:

I've tried this CF and for the simple 10-digit filtered input it seems to work OK, but add in the " x." as a template extension and it breaks down.

Bart Bartholomay, Florida
January 09, 2009 1:37pm

Although I never imagined limiting an extension's length, I tried the template "(###) ###-#### x.###" and the CF returned the expected result from inputs with too few, the right number, and too many digits.

Perhaps Bart will provided more detail, since I cannot find a way to make the result "break down" when I "add in the ' x.'" to template. Anyone getting an unexpected result is welcome to contact me from my web site, (url listed above.)

Geoffrey Gerhard, Matthews, NC
July 01, 2009 12:51pm

Very useful, thanks

Jean-Pierre Bergeron, Montreal, Quebec, Canada
January 06, 2013 4:48am

The masks works great -- thanks for the info!

I do have a small issue. If I send the record (with the masked phone #) via email (i.e. as a PDF file) the two fields print one on top of each other (one with the mask format and the other without) and are unreadable. Do you know of a solution -- other than switching to a difference Layout -- which is not masked?

Thanks!!

Bonnie Gable, Charlotte, NC
April 24, 2013 1:03pm

I am working in filemaker 6, without the "Let" function available (.fp5).

I am trying to convert a phone number field with brackets like this:
(000) 000-0000

the converted value should be minus the brackets like this:
000-000-0000

all the research i see is for Filemaker 7 and newer.

Please advise.

Web, Medford Oregon
August 14, 2016 10:18am

Make a comment about this Custom Function (please try to keep it brief & to the point). Anyone can post:

Your Name:
City/Location:
Comment:
characters left. If you paste in more than 1500 characters, it will be truncated. Discuss the function - advertisements and other useless posts will be deleted.
Answer 4 + 9 =
Search for Custom Functions:

Custom Functions Widget
Download the Custom Function Dashboard Widget for OS X
Keep all the latest Custom Functions right at your fingertips!

Newest Custom Functions:

1. decFromHex ( hexValue )
  (Mon, Oct 16, 12:34pm)
2. MonthYearList ( startmonth ; startyear ; numbermonth ; short )
  (Mon, Oct 16, 3:38am)
3. ErrorDescription ( errorNumber )
  (Wed, Sep 27, 2:51am)
4. decodeEntities (text)
  (Wed, Sep 27, 1:22am)
5. HexidecimalToNumber ( HexidecimalValue ; counter )
  (Mon, Sep 25, 12:39pm)
6. FixedFieldConverter ( Fieldname ; f1 ; f2 ; f3 ; f4 ; f5 ; f6 ; f7 ; f8 ; f9 ; f10 ; f11 ; f12 ; f13 ; f14 ; f15 ; f16 ; f17 ; f18 ; f1
  (Fri, Sep 15, 12:34pm)
7. ShannonEntropy ( text )
  (Thu, Sep 07, 5:59am)
8. LetterCount ( text ; summary )
  (Thu, Sep 07, 5:53am)

RSS Feed of Custom Functions