Defining a specific numeric range in other-specify questions

Last Updated: 04 Aug 2015Hits: 3216
I need to identify the age of a respondent, but I want to make sure they only answer within a specific age range. They also need the ability to opt out of the question. How do I do this?

The nice thing about SSI Web is there is often more than one way to accomplish a task. Below are three different methods to identify a respondent's age.

Select Question: Age Groups

You could create a select question that has multiple age options as well as a "I prefer not to answer" option. For example:1602a

Numeric Question:

You could create a numeric question. In the settings section, you can specify and minimum value, a maximum value, as well as a value for a "I prefer not to answer option." For example:1602b

Select Question w/ JavaScript

There are two options. The first is an "other specify" item so that you can type in a specific value, and the second is the "I prefer not to answer" item. A little bit of JavaScript is added to the question's Advanced Settings > Custom JavaScript Verification tab to generate an error message if the entered number is not within the acceptable range. If the question was called "age" here is what the code might look like:

if ((SSI_GetValue("age_1_other") < 18) || (SSI_GetValue("age_1_other") > 74))
{
 strErrorMessage = "You must enter a number between 18 and 74.";
}

Here's what the question would look like if you typed in a value that was too low:

1602c