Have an idea?

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

Custom Verification not working

I have tried and failed to create a system that will allow me to ask follow-up questions on the same page and only require a response if the first question is a certain answer. Generally both the question and the follow-up are numeric (but not always). I thought I had it working perfectly, but then when I went back to test it again, it was not reading the responses from the same page. This is my current code:

if (SSI_GetValue("b7sym01t") == 1 && [%Not Answered(b7sm01b)%] )
        strErrorMessage = "Must answer treatment question.";

This is the code I THOUGHT was working:
if (SSI_GetValue("b7sym02t") == 1 && document.mainform["[% QuestionName() %]"].value.length == 0)
    strErrorMessage = "Must answer treatment question.";

I need to give the error message if Q1 = 1 and Q2 is blank... both on the same page. It is currently only working if I submit the page then go BACK to the page and try to go forward again.

asked Apr 23, 2015 by ab3886 (310 points)

1 Answer

+1 vote
Hi ab3886,

Try this code!

if ($("#b7sym01t").val()== 1 && $("#b7sym02t").val()== "" )
        strErrorMessage = "Must answer treatment question.";

Let me know if it's not working.

answered Apr 26, 2015 by Raj_0 (425 points)
Nope, did not work. Still allowing me to go through if I put 1 for the Q1 (b7sym01t) and leave Q2 (b7sm01b) blank (I edited your code to be the correct variables). What happens is that it lets me go through on the first try and then if I back up and try to submit again, it won't let me go through.... it gives me the error message after this second attempt to submit. Thoughts???
I actually think I solved the problem (hopefully)!!! I think the issue was that I have my survey set up to allow the right and left arrows to navigate... but I was using the incorrect code for the submit button! It was bypassing the verification process (only when using the arrow keys). I have fixed it and all should be in order.... thanks for the help!!
That's good to hear!!!