Showing example input formats
There are various ways of entering numbers and dates in interviews, all of which depend to some extent on the interview’s language or locale. One of the most common problems relates to the decimal point: is it a comma or is it a dot? If the interview language is one that requires a comma as the decimal point, then any decimal responses that are entered with a dot will be rejected. Similarly, if the language is one that requires a dot as the decimal point, numbers that contain a comma will be rejected. The error message that the user sees depends on the browser language, the script language and locale, and the character entered as the decimal point, but it will usually state either that the response is not numeric or that the thousands separator is not allowed.
You can help respondents and interviewers avoid these problems by displaying an example of the required response format as part of the question. There are several ways of doing this.
Numbers with .Ask()
To mark the point at which the example response should be displayed, place an insert marker inside the question text. (For more information about inserts, see
Programmatically inserting text into labels.)
{Example[:Fmt]}
where
▪Example is the name of the insert marker.
For example:
WeeklyFood "How much do you spend on food in an average week? (e.g.
{spend:f})"
Then, type the Ask() statement as follows:
Name.Ask(Value)
where:
▪Name is the question name.
▪Value is a number.
When the question is displayed during interviews, the insert marker in the question text is replaced with this value, formatted according to the given format string and the interview language. Here are some examples produced by:
WeeklyFood.Ask(1234,5)
Insert
|
Produces
|
{spend:f}
|
1234.50 (English) or 1234,50 (Continental European)
|
{spend:f3}
|
1234.500 (English) or 1234,500 (Continental European)
|
{spend:n}
|
1,234.50 (English), 1 234,50 (French), or 1.234,50 (German)
|
{spend}
|
1234.5
|
Note There is no requirement for the value to be within the valid response range for the question, although it is helpful to respondents if it is.
Dates with .Ask()
To mark the point at which the example date should be displayed, place an insert marker of the following form inside the question text:
{Example[:Fmt]}
where Example and Fmt are as described previously. Then, in the routing section, type:
Name.Ask(CDate("yyyy-mm-dd"))
where:
▪Name is the question name.
▪yyyy, mm, and dd are the date components.
When the question is displayed during interviews, the example date is displayed in the format required by the interview language. For example, if the question is
Expiry "When does your privilege card expire? (e.g.
{exdate})" date;
and the routing section contains:
Expiry.Ask(CDate("2007-12-31"))
the date will be displayed as follows:
Language
|
Date displayed as
|
British English, Western European languages, and equivalents
|
31/12/2007
|
US English and equivalents
|
12/31/2007
|
Eastern European languages and equivalents
|
2007–12–31 (the separator character will vary between countries)
|
Numbers or dates with Format()
The other way of specifying example values for both numbers and dates is to use the standard syntax for defining insert values together with the
Format function
Name.Label.Inserts["Example"].Text = Format(Value, "Fmt", , IOM.Locale)
where:
▪Name is the question name.
▪Example is the name of the insert marker in the question’s metadata.
▪Value is a number enclosed in double quotation marks or a CDate expression defining the value for Example.
▪Fmt is a formatting code the specifies how Value should be displayed.
For example, the previous examples could be written as:
WeeklyFood.Label.Inserts["spend"].Text = Format("12345","f2",,IOM.Locale)
Expiry.Label.Inserts["exdate"].Text = Format(CDate("2007-12-31"),"d",,IOM.Locale)
See also