# Validating units in a text question

**URL:** <https://forum.surveyengine.com/t/validating-units-in-a-text-question/452>\
**Category:** Survey Building\
**Created:** [2 July 2026 16:18 UTC](https://forum.surveyengine.com/t/validating-units-in-a-text-question/452 "2026-07-02T16:18:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Karen](https://avatars.discourse-cdn.com/v4/letter/k/7feea3/32.png) [@Karen](https://forum.surveyengine.com/u/Karen)\
**Post date:** [2 July 2026 16:18 UTC](https://forum.surveyengine.com/t/validating-units-in-a-text-question/452/1 "2026-07-02T16:18:24Z")

</div>

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

 ![image](https://europe1.discourse-cdn.com/flex017/uploads/surveyengine/original/1X/724788048bfe6379640b8cdac5352eb651fd502e.png)

---

<div class="post-metadata">

**Author:** ![Lutz](https://avatars.discourse-cdn.com/v4/letter/l/c4cdca/32.png) [@Lutz](https://forum.surveyengine.com/u/Lutz)\
**Post date:** [3 July 2026 17:16 UTC](https://forum.surveyengine.com/t/validating-units-in-a-text-question/452/2 "2026-07-03T17:16:03Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pharmacprof](https://avatars.discourse-cdn.com/v4/letter/p/47e85d/32.png) [@pharmacprof](https://forum.surveyengine.com/u/pharmacprof)\
**Post date:** [8 July 2026 00:22 UTC](https://forum.surveyengine.com/t/validating-units-in-a-text-question/452/3 "2026-07-08T00:22:58Z")

</div>

Agree with Lutz below. You can also set bounds for whatever units you like. For example, see our screenshot. You can make the corresponding box where people put in responses larger or smaller too (see dimensions).

 ![Screenshot 2026-07-07 at 20.19.04](https://europe1.discourse-cdn.com/flex017/uploads/surveyengine/original/1X/9a5c16b63cd9c46aa90329d70a5434be1d38a2f1.png)
