Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

alert when no answer marked

  • yohay
  • yohay's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
4 years 4 days ago #197400 by yohay
alert when no answer marked was created by yohay
Hi,
I need to check if no answer is checked in a radio button list and when user press continue an alert will pop up asking if he's sure- yes =continue , no= return to page.
I saw in this forum that it can be done but I couldn't incorporate that for radio list question. Im not savvy JS but can "copy and paste" quite well :)

(Survey is set to question by question. Version 2.52)

Your help will be most appreciated
The topic has been locked.
  • yohay
  • yohay's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
4 years 3 days ago - 4 years 3 days ago #197505 by yohay
Replied by yohay on topic alert when no answer marked
Here is the code that I tried and is not working:

<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$('#movenextbtn, #movesubmitbtn').bind('click', function () {
if($('input.radio[value=""]:checked').length > 0) {
var moveOn = confirm("You didnt answer thw question, are you sure you want to move to the next page?");
if (moveOn == false) {
return false;
}
}
});
});
</script>
Last edit: 4 years 3 days ago by yohay.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 3 days ago - 4 years 3 days ago #197532 by tpartner
Replied by tpartner on topic alert when no answer marked
Try this:

Code:
<script type="text/javascript" charset="utf-8">
  $(document).ready(function() {
    $('#movenextbtn, #movesubmitbtn').on('click', function () {
      if($('input:radio:checked').length == 0) {
        var moveOn = confirm("You didn't answer the question, are you sure you want to move to the next page?");
        if (moveOn == false) {
          return false;
        }
      }
    });
  });
</script>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 4 years 3 days ago by tpartner.
The topic has been locked.
  • yohay
  • yohay's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
4 years 3 days ago #197538 by yohay
Replied by yohay on topic alert when no answer marked
Works like a charm. BIG Thanks!

just for learning... why the previous code didnt work? (I saw similar codes were recommended here before for similar topics)
The topic has been locked.
  • yohay
  • yohay's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
4 years 3 days ago #197540 by yohay
Replied by yohay on topic alert when no answer marked
Something new came up regarding this. Hope you can regard to it as well...
I put this message on a timer question and I see when it pop up it stops the timer, can I have this message and still have the timer running on?
Thanks again
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose