This page contains advanced information.
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 design and test your regular expressions, you can use this website: http://www.regexr.com/
Here are some basic examples:
- To restrict a text field to accept only letters (no numbers allowed):
- regex(. ,'^[a-zA-Z]+$') not allowing spaces
- regex(. , '^[a-zA-Z\s]+$') allowing spaces
- To restrict a text field to accept only numbers (no letters allowed):
- regex(. ,'^[0-9]+$')
- To restrict a text field to accept an alphanumeric entry (letters and numbers, no spaces or other characters):
- regex(. , '^[0-9A-Za-z]+$')
- 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.
- It is possible to restrict the input range in a language that uses different Unicode characters, to do that you would input the range of Unicode characters for that language in the regex expression