up Inquisit Language Reference

mask attribute

The mask attribute constrains the text input allowed for a textbox or openended item.

Member of

<openended> <textbox>

Syntax

/ mask = constraint

or

/ mask = regular expression

Parameters

regular expression A regular expression.
constraint One of the following values:
Value Description
alphabetic Only letters are permitted.
alphanumeric Only letters and numbers are permitted.
creditcardnumber The input must consist of 16 digits. The digits may be divided into 4 groups of 4 separated by a dash or space.
date The input must be a valid date in the format mm/dd/yyyy.
decimal Any real number is permitted.
dollars The input must be a valid amount of dollars and cents. Optionally, a dollar sign may be included and commas can be used to delimit thousands.
emailaddress A valid email address.
europeandate The input must be a valid date in the format dd/mm/yyyy.
integer Any valid integer.
ipaddress A valid ip address.
negativeinteger A negative integer.
negativeintegerorzero A negative integer or zero.
positiveinteger A positive integer.
positiveintegerorzero A positive integer or zero.
socialsecuritynumber A social security number in the format nnn-nnn-nnnn.
time A valid time in the format hh:mm.
url A valid url.
ustelephonenumber A phone number in the format nnn-nnn-nnnn.
uszipcode A 5 digit zip code optionally followed by a dash and 4 additional digits.

Remarks

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.

Examples

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>

Send comments on this topic:
Copyright Millisecond Software, LLC. All rights reserved.