The number and integer question types are text input questions designed to accept specific numeric input types. Number questions (type: number) accept positive and negative integers, as well as decimals, whereas integer questions (type: integer) do not accept decimals.
Details
- Both
type: numberandtype: integermay be used in tables by specifyingtype: number tableortype: integer table. - Number and integer questions and tables include default text field sizes of
size: 8andsize: 6, respectively. - Like
type: textquestions, thedatatypetag can be applied to both number and integer questions and tables to alter or redefine which numeric inputs are accepted.
Tags
|
Tag |
Description |
datatype |
Defines the type of input accepted for a response. Frequently used datatypes include: 'number', 'whole', 'integer', and 'decimals'. |
| Sets the maximum length of text that can be entered in the text field. | |
| Sets the minimum length of text that can be entered in the text field. | |
number format |
Specifies formatting for numerical responses. Larger numbers can be automatically displayed with separators (e.g., commas) or restrictions can be placed on the number of decimal places allowed. |
placeholder |
Sets default text in the field that disappears once the respondent starts typing. |
postfix |
Specifies text to be displayed after the text field. |
prefix |
Specifies text to be applied before the text field. |
range |
Defines and validates a numeric range. |
size |
Defines the size (width) of the text field in ems. This tag can be applied to any text question type to override the system defaults. |
Tip! HTML for "non-breaking space" ( ) can be added to accommodate a needed space before or after the prefix and postfix tags, respectively.
Additional examples
Restricting size and numeric input
You can add the size tag to restrict the text field size and the range tag to restrict the numeric input permitted. In the example below, decimals are allowed, but only within the range of 1-12.
Overriding default settings
When using either type: number or type: integer, the datatype can also be overridden. In the example below, we applied datatype: whole to only allow for whole numbers, which are positive integers, including 0.
Number tables
To create a table that accepts both decimal and integer responses, apply type: number table tag. The number format tag has been included to ensure that if decimal responses are entered, they will be truncated to two (2) decimal places and use a comma separator.
"Sum-to-100" tables
Sum-to-100 tables using show column total can be programmed as either number or integer tables. To prevent negative inputs from being entered, you can restrict the range or alter the datatype.
Note, this table could also use the system class add_to_100_percent instead.
Comments
0 comments
Please sign in to leave a comment.