Mask property in inputfields

Mask property is used to specify the input mask for an inputfield .Input masks are helpful for data-entry operations .They show you exactly how to enter  the data in a field.

The input mask definition can contain up to three sections separated by semicolons; for example, (999) 000-0000!;0;*.

Section Meaning
First The input mask itself.Refer the table below to read about the masking elements.
Second Determines whether to store the literal display characters as part of the data.
0 = Do not store literal characters with the value entered.

Any other character or leave blank = Store all the characters including literals.

Third Character that is displayed for blanks or spaces in the input mask. By default, this is the same as the character that stands for literal spaces. The two characters appear the same in an edit window. However, when a user edits the text the cursor selects each blank character and skips over the space character.

The first part of the mask must be a string composed of one or more of the masking elements, as shown below :

Masking element Purpose
! If this character appears in the mask, optional characters are represented in the text as leading blanks. Otherwise, optional characters are represented in the text as trailing blanks.
> If a > character appears in the mask, all characters that follow are in uppercase until the end of the mask or until a < character is encountered.
< If a < character appears in the mask, all characters that follow are in lowercase until the end of the mask or until a > character is encountered.
< > If these two characters appear together in a mask, no case checking is done and the data is formatted with the case the user uses to enter the data.
\ The character that follows a \ character is a literal character. Use this character to use any of the mask special characters as a literal in the data.
L The L character allows only an alphabet (A-Z or a-z) at that position.
I The l character allows only an alphabet at that position. Optional entry.
A The A character allows an alphanumeric character (A-Z, a-z, 0-9) at that position.
a The a character permits an alphanumeric character at that position. Optional entry
C The C character requires any arbitrary character in this position.
c The c character permits any arbitrary character in this position. Optional entry
0 The 0 character requires a numeric character at that position.
9 The 9 character permits a numeric character at that position. Optional entry.
# The # character permits a numeric character or a plus or minus sign in this position. Optional entry.
: The : character is used to separate hours, minutes, and seconds while entering time. If the character that separates hours, minutes, and seconds is different in the regional settings of the Control Panel utility on your computer system, that character is used instead.
/ The / character is used to separate months, days, and years in dates. If the character that separates months, days, and years is different in the regional settings of the Control Panel utility on your computer system, that character is used instead.
; The ; character is used to separate the three fields of the mask.
_ The _ character automatically inserts spaces into the text. When the user enters characters in the field, the cursor skips the _ character.

Any character that does not appear in the preceding table can appear in the first part of the mask as a literal character. Literal characters must be matched exactly in the edit control. They are inserted automatically, and the cursor skips over them during editing. The special mask characters can also appear as literal characters if preceded by a backslash character (\).

Example

For example, the mask for a telephone number with area code could be the following string:

(000)_000-0000;0;*

The 0 in the second field indicates that text would consist of the 10 digits that were entered, rather than the 14 characters that make up the telephone number as it appears in the field.

The third field of the mask is the character that represents blanks (characters that have not been entered) – in the above example  it is ‘*’ .

Note : The character that indicates whether literals should be included can be changed in the Edit Mask property editor, or programmatically by changing the MaskNoSave typed constant.

Some more examples of input masks

The following table shows some useful input mask definitions and examples of values you can enter into them.

 Input mask definition Examples of values
(000) 000-0000 (227) 123-6618
(999) 999-9999! (227) 123-6618
( ) 123-6618
(000) AAA-AAAA (227) 123-TELE
#999 -20
2000
>LLLLLLL000L0 RECEIPT339M3
>L0L 0L0 T2F 8M4
00000-9999 98115-
98115-3007
>LL00000-0000 DB51392-0493