Please help us help you and fill where relevant:
Your LimeSurvey version: 6.5.14
Own server or LimeSurvey hosting: Cloud version
Survey theme/template: Fruity
==================
Hello,
I am a complete newbie when it comes to LimeSurvey. I have now created a survey in which we want to determine prices using the Van Westendorp method.
I have selected "Multiple numerical input" as the question type and defined four sub-questions in which the participants have to enter a price in each case. I have selected the slider as display option (not a must, but nicer). Now I would like to check the values entered by the participants to ensure that the value of sub-question 1 > sub-question 2 > sub-question 3 > sub-question 4. If the check fails, a message should appear asking the participants to change their input.
I have now found and tried various instructions that solve the problem with JavaScript, but none of them have worked. Are there other options or are the JavaScript solutions no longer up to date?
Here is one solution that I have tried:
www.limesurvey.org/manual/Workarounds:_M...meSurvey_version_3.x
ChatGTP suggested the following code:
Code:
<script type="text/javascript">
$(document).ready(function() {
function validateVanWestendorp() {
var answer1 = parseFloat($('input[name="questioncode_SQ001"]').val());
var answer2 = parseFloat($('input[name="questioncode_SQ002"]').val());
var answer3 = parseFloat($('input[name="questioncode_SQ003"]').val());
var answer4 = parseFloat($('input[name="questioncode_SQ004"]').val());
if (isNaN(answer1) || isNaN(answer2) || isNaN(answer3) || isNaN(answer4)) {
return false; // Ensure all inputs are filled
}
if (answer1 > answer2 && answer2 > answer3 && answer3 > answer4) {
return true;
} else {
alert('Bitte stellen Sie sicher, dass Antwort 1 > Antwort 2 > Antwort 3 > Antwort 4 ist.');
return false;
}
}
$('input[name="questioncode_SQ001"], input[name="questioncode_SQ002"], input[name="questioncode_SQ003"], input[name="questioncode_SQ004"]').on('blur', function() {
validateVanWestendorp();
});
$('#movenextbtn').click(function(event) {
if (!validateVanWestendorp()) {
event.preventDefault();
}
});
});
</script>