Visma Net
About input validation options
You can create input masks to help users enter data in a specific format for such elements as
phone numbers, postcodes, and VAT ID numbers.
Also, you can use regular
expressions to validate that the values the user enters not only comply with the
input format but also meet specific requirements.
You create input masks by using the following symbols:
- C - Designates any character
- A - Designates any letter or digit
- L - Designates a letter only
- # - Designates a digit only
- ? - Designates an optional letter
- 9 - Designates an optional digit
You can also use the following control symbols (which are not place-holders) to affect the characters that follow them:
- >
Requires that all letters that follow this symbol are an upper case letter.
If a lower case letter is typed, the system will automatically convert it to upper case. Subsequent > symbols will actually toggle the upper case.
For example: The mask >LL>LL>LL will cause the upper case to be turned off for the second LL characters, but then turned back on for the third LL characters. - <
Requires that all letters that follow this symbol are a lower case letter.
If an upper case letter is typed, the system converts it to lower case. Subsequent < characters will actually toggle the lower case functionality.
For example: The mask <LL<LL<LL will cause the lower case to be turned off for the second LL characters, but then turned back on the third LL characters. - \
Makes the next character be displayed literally, as it is. - ""
Makes characters within the quotation marks be displayed literally.
The following sections provide examples of masks and regular expressions you might use.
Object | Description |
---|---|
United States phone numbers |
The input mask (###) ###-#### will force users to enter the three-digit area code in parentheses, with other seven digits separated by a hyphen (-) in two groups: one with three digits and the other with four digits. If certain input values will always have the same characters, just type the characters within the mask, as is done with the parentheses and hyphen in the previous example. |
United States postcodes | If you want users to enter a five-digit ZIP code followed by a mandatory four-digit
extension, use the mask
#####-####. If, however, you want to make the four-digit extension optional, use a regular expression, such as /^\d{5}([\-]\d)?$/; |
Canadian postcodes | The mask >L#L #L# ensures that the postcode will be entered as two
three-character groups separated by a space:
Only the following letters are actually allowed: The regular expression below ensures that the postcode will
comply with this rule too:
|
United Kingdom postcodes | The format of U.K. postcodes may be represented by a set of
masks:
Some letters (CIKMOV) are not allowed in these codes.
|
In some cases, you may need to set a regular expression to enforce the company's
password policies.
For example: A-regular expression could define valid and invalid
characters, specific formats (for example, the password must begin with a letter),
or minimum and maximum password lengths. Below are some examples of regular
expressions and their explanations:
^(?=.*\d).$ /-
The password must be four to eight characters long and include at least one numeric digit.^[a-zA-Z]\w{3,9}$
The password must be four to ten characters long, the first character must be a letter, and no character is permitted except letters, numbers, and underscores.