I have created a survey using LimeSurvey
tool. For some customization, I have to implement the following task.
Screenshot:
Here, when the user clicks on the Next and if any of the questions are not answered, I want to inform the user that they have missed to answer.
So when they click on Next, I would like to see a confirm box (Javascript) , which displays a message saying you have missed. Ther will be "It is Okay, proceed to next page" button and " I will stay here and answer" button.
"It is Okay, proceed to next page" button should do the same functionality of the "Next" button.
" I will stay here and answer" button will let the users stay in the same page.
I know it is possible using Javascript, I am not sure how to implement this specific task.
I just know that the ID of the Next button is "movenextbtn".
But how will I check whether a question has not been answered when clicking Next button and also using the confirm box how will I proceed to next page or stay in the same page.
Any help would be much much appreciated.
Thanks in advance.
Place this script in the source of the array question:
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
// Identify this question
var thisQuestion = $('#question'+{QID}+'');
// Listener on the "Next" button
$('#movenextbtn').click(function(event){
// Compare number of clicked radios to number of array rows
if($('input.radio:checked', thisQuestion ).length != $('tr.answers-list',thisQuestion ).length) {
// Pop up a confirm message
if(confirm('You have not answered all rows.\n\nAre you sure you want to continue?')) {
return true;
}
else {
return false;
}
}
});
});
</script>