Validating units in a text question

Hi,

How can I ensure that the data input here will be in the format I require?

For example, only numbers (no absurd values and no letters)?

Many thanks

You use what is called a regular expression to describe which values are acceptable. Regular expressions are a way to describe a pattern that the value must match. They look rather arcane until you get used to them.

In your case, if you only want to accept a single digit number as the height in feet you would put the code $height =~ /^[1-9]$/ into the Validation box. However, you might want to allow e.g. optionally up to two decimal digits. Then you could use $height =~ /^[0-9](?:\.[0-9]{1,2})?$/. Or arbitrarily many decimal digits with $height =~ /^[0-9](?:\.[0-9]+)?$/. You can make this as complicated as you like, just google for perl-combatible regular expression (PCRE) or ask your favourite AI.

Don’t forget to fill out the Error Text as well. This is what your respondents will see when they enter an invalid value.