- Posts: 8
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { checkArray(QQ, 'You did not answer the question. Do you really want to continue?') function checkArray(qID, msg) { // Interrupt next/submit function $('#movenextbtn, #movesubmitbtn').click(function(){ var failTest = ''; $('#question'+qID+' tbody[id^="javatbd"]').each(function(i) { if($('input.radio:checked', this).length < 1) { failTest = 1; $('th, td', this).css({'background':'pink'}); } else { $('th, td', this).css({'background':''}); } }); if(failTest == 1) { if(confirm(msg)) { return true; } else { return false; } } }); } }); </script>
Yes, you can just modify the message in the function call:...but is it also possible to make the pop-up message say which question was left unanswered?
checkArray(QQ, 'You did not answer question 4. Do you really want to continue?');
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { checkArray(QQ, 'You did not answer the question. Do you really want to continue?'); function checkArray(qID, msg) { // Interrupt next/submit function $('#movenextbtn, #movesubmitbtn').click(function(){ var failTest = ''; $('#question'+qID+' tbody[id^="javatbd"]').each(function(i) { if($('input.radio:checked', this).length < 1) { failTest = 1; $('th, td', this).css({ 'background':'pink' }); } else { $('th, td', this).css({ 'background':'' }); } }); if(failTest == 1) { if(confirm(msg)) { return true; } else { return false; } } }); } }); </script>
Yes, you can put this in template.js but if you want to check every question in the survey, you will need different code for every question type and search for those types on every page.Is it possible to insert such a piece of code into the template instead of putting it in each question...