The numberformat
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
-
numberformat
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.,
numberformat: 0,0
ornumberformat: #,#
). - If a grouping separator has been specified via
numberformat
, e.g.,numberformat: 0,0
, the separator will be applied by the system as a response is entered. - By default, grouping separators are applied every three (3) digits; e.g. if the respondent entered "345678," the system would format it as "345,678".
- System-generated separators are not stored when the response is submitted, so 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 then 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
numberlocale
tag. - The
currency: y
decorator can be applied to display a currency symbol in the text field. By default, a '$' will be displayed unless thenumberlocale
tag has been added.
Accepted formats
Examples of accepted formatting for numberformat
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 |
0[.]0 or #[.]#
|
Decimals optional to one (1) place |
0,0[.]00 or #,#[.]##
|
Add separators; decimals to two (2) places optional |
0,0.00 or #,#.##
|
Add separators; decimals to two (2) places permitted |
Tags and decorators
Commonly used tags
The following tags are commonly used with numberformat
.
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., |
numberlocale |
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. |
showcolumntotal |
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 numberformat
. When including multiple decorators, each should be in their own set of curly braces — e.g., numberformat: 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.