What is an input mask?
An input mask is like a face mask. A face mask covers the opening (mouth) that otherwise would allow bad things into the human body. An input mask is similar. It acts like a mask by preventing bad things from being entered into a database field.
An input mask is a textual pattern for acceptable data. Its textual because certain special characters have specific meaning. For example, the character 0 means a digit is required. Those characters are then put together in a specific order or pattern that represents the type of data that can be entered. For example, a phone number that requires an area code in parenthesis might have the following input mask:
Characters and their meaning
Below is a list of the special characters and their meaning:
[table id=9 /]
In addition to the special characters, the input mask can have two additional sections. Each section is separated from the previous section by a semicolon.
[table id=10 /]
Section 2 – Storing literal characters
The second section of the input mask determines if literal characters are saved on the disk. Literal characters are those extra characters that format a number or text entry. For example the parenthesis surrounding an area code are literal characters. Dashes in a Social Security Number are another example of literal characters.
If you save, for example, a phone number without its literal characters, than on the disk it would be saved as just 10 digits: 4081234567 even though the input mask will display it on the screen as 14 characters: (408) 123-4567.
To have literal characters saved on the disk, enter a 0 in the second section, otherwise leave the second section blank as shown below.
[table id=11 /]
Section 3 – Placeholders
When displayed on the screen, an underscore or some other character can be used as a placeholder. This will make it obvious to the users where they data can be entered. If a placeholder character is not entered in the third section, Access will by default display an underscore. If you want a different character, just enter it in the third section. If you want to use a space as the placeholder, enter a space between two quotation marks.
[table id=12 /]
Input Mask Cautions
Input masks can cause problems, especially if they are changed. For example, suppose you have a phone number field input mask such as \(999″) “000\-0000;0;. Notice the 0 in the second section instructs Access to store the parenthesis, dashes and phone numbers. Suppose you then change the input mask to remove the parenthesis: 999\ 000\-0000;0;. If the user then needs to edit the digits of a previous phone number. Access will display the following error unless they remove the parenthesis.
Input masks can also be a problem when the user navigates with their mouse. For example, in the screen shot below the user clicked in the middle of the Phone number field. Notice that the mouse put the cursor in the middle of the field. Before they enter the phone number the user will need to manually reposition the cursor at the beginning of the field.
In this post we have stated that an input mask is like a face mask – it can be used to filter the type of data that can go into a field. It can also provide literal characters that will bring consistency to phone numbers, zip codes, and other fields. We have learned that the literal characters can be stored in the field, or just used to format the field’s display. Finally we learned that input masks are not perfect, and can cause problems if they are ever changed, or if the user selects the field with their mouse.
Tell us what you think. Have input masks helped you, or are they more trouble than their worth?
Now that you have learned about input masks, can you determine how they will be used? Click on the mask to see the answer.[vc_toggle title=”000-000-0000″]Phone # with area code and slashes as separator
408-123-4567[/vc_toggle][vc_toggle title=”000.000.0000″]Phone # with area code and periods as separator
408.123.4567[/vc_toggle][vc_toggle title=”(999”) “000-0000″]Phone # with optional area code inside parenthesis, and a space and dash as separators
( ) 123-4567[/vc_toggle][vc_toggle title=”(000”) “000-0000″]Phone # with area code inside parenthesis, and a space and dash as separators
(408) 123-4567[/vc_toggle][vc_toggle title=”00000-9999″]Zip code with 5 required digits and 4 optional digits
12345-6789[/vc_toggle][vc_toggle title=”00/00/0000″]Date with a two-digit day, two-digit month, and four-digit year
04/15/2020[/vc_toggle][vc_toggle title=”90/90/0000″]Date with a one or two-digit day, one or two-digit month, and four-digit year
04/15/2020[/vc_toggle][vc_toggle title=”L00 ?999″]A code that starts with a letter, followed by two digits, then a space, then an optional letter with three optional digits