Constraint settings control the text that the user is allowed to input. For example, you can limit input to a range of numbers, to a particular length, or to a specific pattern, such as the common ###-####.
Constraint settings follow this syntax:
<format>
<constraints>
<settingname1>setting</settingname1>
...
<settingnamen>setting</settingnamen>
</constraints>
</format>
The following list defines that valid settings:
Default: none.
100.00
List each separator in its own separator tag, as shown:
<decimalseparators>
<decimalseparator1
>separator</decimalseparator1>
...
<decimalseparatorn
>separator</decimalseparatorn>
</decimalseparators>
You can use any string, such as a comma or a comma followed by a space. This setting is only valid for integer, float, and currency data types.
Note:
Default: a comma.
1,000,000
List each separator in its own separator tag, as shown:
<groupingseparators>
<groupingseparator1
>separator</groupingseparator1>
...
<groupingseparatorn
>separator</groupingseparatorn>
</groupingseparators>
You can use any string, such as a comma or a comma followed by a space, with the keyword none representing no separator at all. This setting is only valid for integer, float, and currency data types.
Usage details
Default: a comma.
<length>
<min>shortest length allowed</min>
<max>longest length allowed</max>
</length>
For example, if you wanted all values to be between 4 and 7 characters in length, you would set the min to 4 and the max to 7. This allows the user to enter a value that is either 4 characters or 7 characters in length, as well as all lengths in between.
The length is calculated after all formatting has been applied, and will include all formatting characters such as the negative sign, currency symbols, and so on.
If you add a length setting to a field, the field is treated as mandatory.
Default: the maximum range of lengths allowed for the data type.
This value works in conjunction with the required property for the linked element in the XForms model. If either setting indicates that input is mandatory, then it is mandatory.
Default: the required property of the linked XForms data element, or off.
Default: none.
You must define each pattern in its own <pattern> tag, as shown:
<patterns>
<pattern1>pattern</pattern1>
...
<patternn>pattern</patternn>
</patterns>
If you define more than one patternref in the presentation settings, you must define an equal number of patterns in the constraints. Each patternref is then matched to the corresponding constraint pattern. For example, the first patternref is matched to the first constraint pattern, the second patternref is matched to the second constraint pattern, and so on. This allows you to define a different pattern for each constraint.
Note that unlike the template setting, the pattern setting does not show users any of the text you include in your patterns, since there is no way to tell which pattern the user will follow.
<range>
<min>smallest number allowed</min>
<max>highest number allowed</max>
</range>
The low and high values are inclusive. For example, if you wanted to create a range from 1 to 100, you would set the low value to 1 and the high value to 100. This allows the user to enter either 1 or 100, as well as all values in between.
If you set a range for a string, the data is evaluated on a character by character basis. For example, you might set your low value to “fg” and your high value to “jk”. In this case, the first character entered would have to be in the f-j range, and the second character would have to be in the g-k range. This check ignores case.
Default: the maximum range allowed for the data type.
To create a template, use a wild card to represent any 1 character that the user types in. All other characters are shown to the user as typed.
For example, if you create the following template:
(...)...-....
The user will see the following:
( ) -
Setting a template in limits user input to the format set by the template. If the user attempts to enter incorrect data, it is rejected either by a warning message or by predictive input checking in the Viewer (if enabled).
To set a fixed date, you must include the <fixedyear> tag as shown:
<yearwindow>
<fixedyear>the year</fixedyear>
</yearwindow>
To set a sliding date, you must include the <factor> tag as shown:
<yearwindow>
<factor>range</factor>
</yearwindow>
You can set either a fixed date or a sliding date, but not both. If you do set both, the sliding date will override the fixed date.
Default: a sliding date with a factor of 30.