18. Working with Data Types and Data Display Formats : String Input Templates : How to Force Mandatory Entry
 
Share this page                  
How to Force Mandatory Entry
Mandatory entry means that the user cannot leave the field without supplying a valid entry for that position. If they attempt to leave the field without providing a valid entry, they receive an error message and the cursor is positioned at the beginning of the template.
To specify mandatory entry, you use an uppercase special character, either built‑in or user‑defined. For example, assume that you want the user to enter a part number that has a two‑letter code followed by two numbers and one final letter, and that the first two letters are mandatory. Your template looks like this:
AAnna
Perhaps the part number uses a restricted letter set, for example A‑D. Your template looks like this:
[K=a‑d]Knnk
The user must enter one of the letters from A to D in the first two positions; this is enforced by the uppercase K. Making an entry in the final position is optional, but it must be a letter from A to D also.