Have an idea?

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

Force respondents to read question for 15 sec

This is the code I found in this forum.
https://sawtoothsoftware.com/forum/10708/keep-question-on-screen-for-set-time
<script type="text/javascript">
$(document).ready(function(){
    $('.submit_div').hide();
    setTimeout(function(){
        $('.submit_div').show();
    }, 15000);
})
</script>


Instead of hiding and showing submit button, I want to show error message if submit button is clicked within 15 seconds after this question is shown. Is this possible?. Please help me.
asked Feb 15, 2017 by Abdul Bronze (2,630 points)

1 Answer

+2 votes
 
Best answer
Put this code in the question's footer:

<input type="hidden" id="timer"/>

<script>
$(document).ready(function(){
    var timer = 0;
    setInterval(function(){
        timer++;
        $('#timer').val(timer);
    }, 1000);
})
</script>


Then give the question this custom JS verification:

if (Number($('#timer').val()) < 15) {
    strErrorMessage = 'Error.';
}
answered Feb 15, 2017 by Zachary Platinum Sawtooth Software, Inc. (147,925 points)
selected Feb 16, 2017 by Abdul
Thanks Zachary. It works great.
...