Have an idea?

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

Free Format - Radio Button - Other Specify - How do I require an answer


I have a list of 28 brands, the respondent will select the brands he or she uses.

The next question takes the brand selected and ask a yes or no question.

The next question brings in the brands that the respondent said yes to and ask a question that is either lbs or Other (specify) along with other questions.  

I had to create a free format question because of look of the table my client is looking for

Size of Containers or Bags Used:

----------| -- lbs
               |  -- Other (specify)

I have 2 radio buttons, 1 for lbs and 1 for other specify, the I have a text box (which I made the setting not required).

My issue is that if the respondent selects the radio button for other specify but does not type in an other answer the survey will continue.  I would an alert message to pop up.

I have tried this code but it doesn't work

if (document.getElementById("OTH_c2r1").checked && document.mainform["Q2b_c2Othr1"].value == "" || document.getElementById("OTH_c3r1").checked && document.mainform["Q2b_c3Othr1"].value == "")
    strErrorMessage = "You selected Other (specify) for Barricade but did not type in the other response.  Please review to continue.";
if (document.getElementById("OTH_c2r2").checked && document.mainform["Q2b_c2Othr2"].value == "" || document.getElementById("OTH_c3r2").checked && document.mainform["Q2b_c3Othr2"].value == "")  
    strErrorMessage = "You selected Other (specify) for Bensumec but did not type in the other response.  Please review to continue.";
if  (document.getElementById("OTH_c2r3").checked && document.mainform["Q2b_c2Othr3"].value == "" || document.getElementById("OTH_c3r3").checked && document.mainform["Q2b_c3Othr3"].value == "")
    strErrorMessage = "You selected Other (specify) for BroadStar but did not type in the other response.  Please review to continue.";

I would also like to erase the other specify text, if the respondent changes his/her mind and selects the radio button for lbs.

I would appreciate any help.

thank you much
asked Jul 5, 2018 by anonymous
What is the name of the radio variables in your free format question?  You may not be using the correct IDs to select the radio button elements by.  If your free format's code uses Sawtooth Script like this:

[% RadioSelect(OTH_c2, 1) %]

then the JavaScript you'll want to use to read the checked state would be:


Am I going down the right path here?
My radio button for lbs  is being defined as <input type="radio" name="Q2b_c2Unitr1" id="LBS_c2r1" value="1" onclick="Cleartxt();"> lbs. </input>

My other specify radio button is
<input type="radio" name="Q2b_c2Unitr1" id="OTH_c2r1" value="97" > Other (specify) </input>


My other specify text box is:

<input name="Q2b_c2Othr1" id="Q2b_c2Othr1" type="text" maxlength="72" size="15">
Thanks for the HTML.  I've done some quick testing using your HTML and this JS:

document.getElementById("OTH_c2r1").checked && document.mainform["Q2b_c2Othr1"].value == ""

but am yet to observe anything problematic.  The JS returns true when the second radio is selected and the text box is empty, and false otherwise.  Can you expound more on what problem you are observing?  Is there a special behavior you want to achieve by putting "OTH_c2r1" and "OTH_c3r1" checks in the same conditional?
In addition, are there any error messages appearing in your browser's console when you submit this survey page?
May I send over my survey?  It works fine when all of the brands have the same answers but the survey freezes when say 2 brands have the same answer and 1 has a different answer.
I think I have came up with a fix.  I am leaving the office and will work on this from home.

Thank you for your help
My solution did not work- any help would be greatly appreciated
You can send in your .ssi to support@sawtoothsoftware.com.

Your solution to the original question

Please only use this to answer the original question. Otherwise please use comments.
Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:

To avoid this verification in future, please log in or register.