The number format
tag specifies formatting for numeric responses, such as grouping separators (e.g., commas in the United States) or the number of allowed decimal places.
Details
-
number format
can be applied totype: number
andtype: integer
questions and tables, as well astype: text
questions and tables that include a numeric datatype such asdatatype: whole
. -
Formats can be specified with either 0's or #'s (e.g.,
number format: 0,0
ornumber format: #,#
). - If a grouping separator is specified, the separator will be applied by the system as a response is entered.
- By default, grouping separators are applied every three (3) digits. If the respondent enters "345678," the system formats it as "345,678."
- System-generated separators are not stored when the response is submitted; the data is saved as the numeric value entered.
- The numeric value entered can be piped like an open-ended response, e.g., '$QX'. The formatted value can be piped like a close-ended response by adding '_text', e.g., '$QX_text'.
- To apply number formatting and currency symbols for locales outside of the US, include the
number locale
tag. - The
currency: y
decorator can be applied to display a currency symbol in the text field. By default, a '$' will be displayed unless thenumber locale
tag has been added.
Accepted formats
Examples of accepted formatting for number format
inputs are shown below. Note the number of 0's or #'s after a decimal indicates the number of decimal places allowed.
Number format | Description |
0 or #
|
Integers only; no separators added. |
0,0 or #,#
|
Add separators; decimals not permitted. |
0.00 or #.##
|
Decimals to two (2) places permitted. If none are entered, two decimal places are added by the system. |
0[.]0 or #[.]#
|
Decimals to one (1) place are optional. |
0,0[.]00 or #,#[.]##
|
Add separators; decimals to two (2) places are optional. |
0,0.00 or #,#.##
|
Add separators; decimals to two (2) places permitted. If none are entered, two decimal places are added by the system. |
Tags and decorators
Commonly used tags
The following tags are commonly used with number format
.
Tag | Description |
datatype |
Specifies which response type is accepted. Common options include: 'number', 'integer', 'whole', 'decimals'. |
maxlength |
Specifies the max number of characters that can be entered, including decimal separators. Note this can affect the largest value accepted (e.g., |
number locale |
Specifies a language/locale code to alter the number formatting for countries outside of the US. When combined with the |
postfix |
Specifies text or a symbol to be shown after the respondent text field. |
prefix |
Specifies text or a symbol to be shown before the respondent text field. |
range |
Specifies the accepted response range. |
show column total |
Include with numeric input tables to create a "total" row that sums up the respondent's answers. |
size |
Specifies the width (in ems) of the text field. |
Note: HTML for "non-breaking space" (
) can be added to accommodate a needed space after and before the prefix
and postfix
tags, respectively.
Supported decorators
The following decorators can be used along with number format
. When including multiple decorators, each should be in their own set of curly braces — e.g., number format: 0,0 {delay: 250} {currency: y}
.
Decorator | Description |
currency |
Accepts 'y' and 'n' inputs. Set to 'y' to add currency formatting and symbols to respondent input. When combined with |
delay |
Specifies the amount of time in msec to wait before adding formatting to a response; defaults to '500'. Use delay: 0 to add the separators immediately. |
Comments
0 comments
Please sign in to leave a comment.