Sometimes there are inputs which require not only a valid range (IE: between 96 and 105), but a specific number of significant figures (96.6, not 96.65 or 96) or other specific structure (A1234). To set this up, you can use a constraint in the Validation Condition section for a field with a Regular Expression.

To restrict a text field to accept an alphanumeric entry (letters and numbers, no spaces or other characters):

regex(. , '^[0-9A-Za-z]+$')

Considerations

It is important that the input type for this question be text, not number, integer, or decimal; therefore you should use the question type "Text" or "Numeric ID/Phone Number" (this question type is technically text with a numeric keyboard appearance). Numbers are represented and compared by their numeric value, so "65.00" and "65" are equivalent.

These validation example often don't validate the actual size of the number at all. You can similarly restrict the values before the decimal sign in your expression using regular expressions, but remember that if it is difficult to express whether a value is valid, users may have a hard time entering the correct value.

Examples

Example 1: Require a specific number of significant figures

Icon

To require an input with an arbitrary size, but always with two significant figures, you can use the following:

Valid Inputs: 34.00, 4.32, 0.23

Invalid Inputs: 34, 0.0, 2.3, 34.2222

Enter into Validation Condition = regex(., '^[0-9]*\.[0-9][0-9]$' )

the two [0-9] elements at the end are the placeholders for the significant figure digits. You can add or remove more to manipulate the number of digits

Example 2: Require up to a specific number of significant figures

Icon

If you want to specify that the expression can have up to two significant figures the expression is somewhat more complex: