Have an idea?

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

Numeric Response

Hi,

In case of numeric response with valid range of say 1-10 & 21-50.
And with range in between say 11-20 being invalid.

How do we incorporate this range in the script with proper checks

Regards
asked Dec 24, 2012 by mal_saw2001 Bronze (875 points)

1 Answer

0 votes
We've just squeezed into Xmas day here in Australia but I'll get one more support in before Santa rocks up.

You will need to insert some JavaScript code into your numeric question. Click on the "Advanced" button at the bottom of the question then click on the "Custom JavaScript Verification" tab (top right hand corner).

My JavaScript isn't very strong but this should work.
 
Assuming your question is Q1, enter the following ...

var count=0

if(document.mainform["Q1"])
 {
  if((document.mainform["Q1"].value>=11)&&(document.mainform["Q1"].value<=20))
   {
    count=count+1;
   }
 }

if (count>0)
  {
   strErrorMessage="You must enter a response in the range of 1-10 & 21-50. Please review your answer before continuing.";
  }
  
else
 {
  strErrorMessage="";
 }


Note - you should enter the numeric question range as minimum value=1 and maximum value=50.
answered Dec 24, 2012 by Paul Moon Platinum (57,565 points)
Thanks a lot Paul!
...