Have an idea?

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

Ask follow-up question on same page using custom JS verification

I thought I had this issue solved, but apparently not. I have two questions on one page, Q1 (b7sym01t) and Q2 (b7sm01b). Q1 is required... if Q1 = 0, then Q2 should stay hidden and not require an answer. If Q1 = 1, then Q2 should show itself and require an answer (0 or 1). The hiding/showing code is working fine. I had code working well for the custom verification but it was reading the 0 as unanswered.

This is my current code for the custom verification for Q2:

if (SSI_GetValue("b7sym01t") == 1 && SSI_GetValue("[%QuestionName()%]") === null)
        strErrorMessage = "Must answer treatment question.";

I tried using "" instead of null, but it keeps allowing unanswered questions to pass. I also tried to use "Not Answered", which didn't work correctly either!! I also tried using the length as zero (if (document.mainform["b7sm01b"].value).length == 0))... PLEASE HELP!!!
asked Apr 14, 2015 by ab3886 (310 points)
What is the question type of Q2 (single select / numeric / ... )?
All questions are numeric. I THINK I may have solved it using the length of the response (not sure what I did differently this time because it wasn't working before)...
if (SSI_GetValue("b7sym15t") == 1 && document.mainform["[% QuestionName() %]"].value.length == 0)
        strErrorMessage = "Must answer treatment question.";

If you have a better idea, please let me know!

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.