alert when no answer marked

More
2 months 2 weeks ago #197400 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

Please Log in to join the conversation.

LimeSurvey Partners
More
2 months 2 weeks ago - 2 months 2 weeks 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: 2 months 2 weeks ago by yohay.

Please Log in to join the conversation.

More
2 months 2 weeks ago - 2 months 2 weeks ago #197532 by tpartner
Try this:

<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.
Official LimeSurvey Partner - partnersurveys.com
Last edit: 2 months 2 weeks ago by tpartner.

Please Log in to join the conversation.

More
2 months 2 weeks 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)

Please Log in to join the conversation.

More
2 months 2 weeks 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

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now