Automatic Field Formatting - As you type!

"Can FileMaker automatically apply formatting to my fields?", this is not just a common question, it's been a critical complaint as well. What many other desktop database solutions have offered was an easy way to apply masking. Often as easy as setting the mask into the properties of the field itself - a super simple solution - yet, not so simple in FileMaker.

Well, the day has come and you can now do the type of masking you're actually thinking about. Not just post-field-entry masking or using one field to overlay on top of another field, what we're talking about is as-you-type field masking.

It's easily accomplished with an OnObjectKeystroke trigger, the not-so-easy part is managing all the different possibilities of what can be happening when a user is typing content.

Hopefully, by using this file, and the included video content, you'll realize that the automatic field formatting you've always dreamed of, is actually here. Add any of your tips or suggestions to the bottom of this article!

AttachmentSize
AutomaticFieldFormatting.zip234.67 KB

Comments

Having written a fairly comprehensive routine for this purpose (Small Company's Ergonomic Stimulus Award winner in February 2009) I was curious to see your implementation. In your Full Number field, enter (555) 666-777, then shift left arrow to highlight the last 7, then hit delete: All 7s are gone! Turns out that highlighting any single digit and deleting it will delete all other instances of that digit in the string.

Also, there's some inconsistency in the way the "formatting characters" are treated. Put the curser to the right of the "-" and hit the backspace/delete. The cursor moves to the left of the dash without apparently deleting it. With the cursor still to the left of the dash, hit the forward delete. The dash is deleted and disappears from the field. Same thing with the parentheses bracketing the area code. If backspace appears to "step over" formatting characters, the forward space should do the same.

When editing a number, the cursor should advance so that the insertion point always follows the number you just typed. Your example file does not. Type 1237890, then arrow back so the cursor sits between the 3 and the ), then type 456. You end up with (123)-654-7890. You should have ended up with (123)-456-7890.

And while we're picking nits: what's up with the dash between the area code's closing parenthesis and the prefix? I've always seen a space character there, never a dash.

An example file that solves all of the above problems and offers customizable mask structures is available here:

http://www.creativesltns.com/contact.htm

Click the "Download" link under the "Field Masking Demo..." subhead. As noted in the file's Discussion section, there's still room for improvement.

Hi....Script works great accept for if the user doesn't enter the required amount of digits. for example on the phone number I can enter only a couple of digits and FileMaker will save the fields data. How can I enforce that the full 10 digit phone number has to be entered?