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.
Try it!
Details
- Both
type: number
andtype: integer
may be used in tables by specifyingtype: number table
ortype: integer table
. - Number and integer questions and tables include default text field sizes of
size: 8
andsize: 6
, respectively. - Like
type: text
questions, thedatatype
tag 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'. |
(alias |
Sets the maximum length of text that can be entered in the text field. |
(alias |
Sets the minimum length of text that can be entered in the text field. |
numberformat |
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. Respondents must input decimals themselves for non-integer values. |
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 after or before the prefix
and postfix
tags, respectively.
Additional examples
Restricting size and numeric input
The inclusion of the size
tag will restrict the text field size, and the range
tag will 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 have applied datatype: whole
to only allow for whole numbers, which are positive integers, including 0.
Number tables
To create a text table that accepts both decimal and integer responses, apply type: number table
. The numberformat
tag has been included to ensure that if decimal responses are included, they will be truncated to two (2) decimal places and will use a comma separator.
"Sum-to-100" tables
Sum-to-100 tables using showcolumntotal
(alias sct
) can be coded as either number or integer tables, though you may need to restrict the range or alter the datatype to prevent negative inputs from being entered.
Note, this table could also use the system class add_to_100_percent instead.
Comments
0 comments
Please sign in to leave a comment.