Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

"Other" specify box for numeric values only

I have a radio question where the last question was set as "Other Specify".  I'd like to limit the open end to numeric values only within a range of 1 to 31.  How can I accomplish this?

Thank you!
asked Mar 8 by anonymous

1 Answer

+1 vote
 
Best answer
Add this custom JavaScript verification to your select question:

var otherSpecifyItem = 5;
if (SSI_GetValue('[% QuestionName() %]') == otherSpecifyItem) {
    var other = SSI_GetValue('[% QuestionName() %]_' + otherSpecifyItem + '_other');
    if (!/^\d+$/.test(other)) {
        strErrorMessage = 'Only numeric characters are allowed.';
    }
    else {
        var number = Number(other);
        if (number < 1 || number > 31) {
            strErrorMessage = 'Number must be between 1 and 31.';
        }
    }
}


The first line should be updated with which item of the select question has the other specify field.
answered Mar 8 by Zachary Platinum Sawtooth Software, Inc. (114,850 points)
...