Allow only numbers and special characters in text field

I’m creating a form where I need to enter the ages of patients which include infants as well, the method devised by upper management is that for infants it will be (<1 upto <12) and then from there 1, 2, 3 upto 100. Now this is not something that can be accomplished with the number field, so I was wondering if there was some way to accomplish this in text field or any other way. I could have used cascading style but that would include two columns, I want the data to enter only a single column “age”.

Some options:

  • Use a long select_one choice_list (drop down), inkl. < 1 month etc.
  • Use an age year integer question (0 … 120) and an optional months (integer or select_one) question for age < 1 year.

As you probably ask for completed years/age, you might better use this for the months too, (e.g. “1 month” instead of “< 2 months”). Also this seems clearer: “< 2 months” here means at least 1 month (up to 2 months excluded).

I would prefer the second option as it keeps the dimension of the age variable on one consistent (age) level. It also seems better for analysis.

For both options you might add a calculate numeric variable to combine the data: conversion to months for all values or conversion of < 5 .years to year decimals.

1 Like

@Fakhr, adding to @wroos, I would advise you as follows:

  • Have an integer question that can intake an input from 0 to 100.
  • Have another integer question that can take 0 to 12 months. This integer question will only be active if the previous age question is 0 (i.e., recorded as an infant) using the skip logic.

I hope this approach works for you. But hopefully, our community should also be able to chime in with other workarounds.

Hint: Probably the second question should go until 11 (months) only, counting completed months. (12 months = 1 year already).

Also constraints to limit the valid number ranges would be needed.

1 Like