I am creating a Limesurvey which should be the second part of a long-term study.
In the first study, every participant had to enter their so-called "Mothercode". This code will enable them to see their results from that first study once again at the beginning of Study #2 (current one).
The problem I'm facing is that if the participant enter a wrong code, they should NOT be able to CONTINUE the study anymore. (Everything else - e.g. presenting the results - works just fine!)
Is it possible to do that with LS? Notice, that there are 750 entered codes in total and that I would not be pleased to create a condition for each one of them!
There may be some magic way to do it with Expression Manager but it doesn't come to me. An alternative would be to use JavaScript to hide the "Next" button and put a listener on the text input that checks the value against an array of codes.
Something like this in the question source:
Code:
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
// A list of the "Mothercodes"
var codes = ['abc123', 'abc124', 'abc125', 'abc126'];
// A function to hide/show the "Next" button
function handleNext() {
$('#movenextbtn, #movesubmitbtn').hide();
if($.inArray($.trim($('#question{QID} input[type="text"]').val()), codes) >= 0) {
$('#movenextbtn, #movesubmitbtn').show();
}
}
// Initial state
handleNext();
// Listener on the text input
$('#question{QID} input[type="text"]').on('keyup change', function(i) {
handleNext();
});
});
</script>
Hello everyone
I ask in this topic to avoid not making a new one.
I need to do something similar to this question
I need to validate if the code entered is already in the response database (lime_sourvey_xxxx) and if it finds it send an alert and restart the survey. The code is the first question in the survey.
I know I need to create a php, but I do not know anything about programming.
If someone could guide me on how to make that code and call it in my survey, I would be very grateful.
If I already have the php that makes the query to database
how to code and insert the result that query sends me to validate and show the alert message
Thanks for the code, tpartner. I tried it, but it doesn't work properly though.
I understand that I have to adjust the QID Number, within the 'handleNext()' function and the 'listener', right?
Because the QID of the Input Field, where the 'mothercodes' will be typed in, has the ID number '30156', i thought it has to be something like this (which doesn't work still).