Please help us help you and fill where relevant:
Your LimeSurvey version:
Community Edition
Version 6.4.0+231218
Own server or LimeSurvey hosting: University hosting
Survey theme/template: Bootstrap Vanilla
==================
Hello, I want to implement a feature that enhances the user experience. Specifically, I want to create a warning message that activates when participants click the "Next" button to proceed to the following page. This message should alert them if they haven't answered all the questions on the current page, asking for confirmation if they wish to continue despite unanswered questions. I aim to ensure missing questions are due to a conscious decision rather than oversight without enforcing mandatory responses. Could you provide guidance or suggestions on how to implement this warning mechanism in a user-friendly manner effectively?
I have tried to insert this code in the custom.js of my template (replacing with my actual code ID):
$(document).on('click', '#movenextbtn, #movesubmitbtn', function() {
var unanswered = false;
var questionsToCheck = [
'#questionID1', // Replace with the actual ID of your multiple choice question
'#questionID2', // Replace with the ID of your conditional multiple choice question
'#questionID3', // Replace with the ID of your array text question
'#questionID4', // Replace with the ID of your short free text question
'#questionID5' // Replace with the ID of your numerical input question
];
questionsToCheck.forEach(function(question) {
if ($(question).is(':visible')) {
if ($(question).find('input:checked, input:text[value!=""], textarea[value!=""]').length == 0) {
unanswered = true;
}
}
});
if (unanswered) {
return confirm('You may have missed answering one or more questions. Do you still want to proceed?');
}
});
However, it had no effect. Where should I place the js code, and what would get me the desired result?
Thank you!