The mask attribute constrains the text input allowed for a textbox or openended item.
or
/ mask = regular expressionregular expression | A regular expression. | ||||||||||||||||||||||||||||||||||||||||
constraint |
One of the following values:
|
The mask attribute provides a powerful set of tools for defining what type of text input is valid for a textbox survey item. It can be used, for example, to allow numberic only, or a date, a phone number in a specific format, or just about any pattern of text. Inquisit provides a set of built in patterns that can be used. If none of the ready-made patterns are appropriate, custom patterns can be defined using regular expression syntax. The web is full of resources for generating regular expressions that validate a wide range of input. For example, see https://utilitymill.com/utility/Regex_For_Range for a tool that generates expressions constraining input to a range of integer values.
The following restricts the input to a valid email address:
<openended email>
/ stimulusframes=[1=enteremail]
/ mask = emailaddress
</openended>
The following restricts the input to an integer:
<openended integer>
/ stimulusframes=[1=enterinteger]
/ mask = integer
</openended>
The following uses a regular expression to restrict the input to an integer from 0 to 100:
<openended integer>
/ stimulusframes=[1=enterinteger]
/ mask = ^0*([0-9]{1,2}|100)$
</openended>
The following uses a regular expression to restrict the input to an integer from 0 to 200:
<openended integer>
/ stimulusframes=[1=enterinteger]
/ mask = ^0*([0-9]{1,2}|1[0-9]{2}|200)$
</openended>
The following uses a regular expression to restrict the input to an integer from 1 to 99:
<openended integer>
/ stimulusframes=[1=enterinteger]
/ mask = ^0*[1-9][0-9]?$
</openended>