Check out the LimeSurvey source code on GitHub!

Filter answers of a question with the answer of another

5 years 4 months ago #65899 by hozkarcr
in my survey
(Question 1) Write your email address
(Question 2) Repeat the email address

i need validate that answers in question 1 and question 2 are equals

It`s possible ?

Please Log in to join the conversation.

5 years 4 months ago - 5 years 4 months ago #65927 by tpartner
1) Set up your survey to use JavaScript .

2) Add the following script to the source of the one of the questions. Replace "11" with the first question ID and "22" with the second question ID .

The script puts a listener on the text inputs. If there is a change to one of them and they don't match an alert is popped up and the offending input is cleared.
<script type="text/javascript" charset="utf-8">
	$(document).ready(function() {
		var q1ID = 11;
		var q2ID = 22;
		var msg = 'The email address does not match, please re-enter it.';
		// Listener on the text inputs
		$('#question'+q1ID+' input.text, #question'+q2ID+' input.text').change(function(){ 
			var text1 = $('#question'+q1ID+' input.text').val();
			var text2 = $('#question'+q2ID+' input.text').val();
			if(text1 != '' && text2 != '' && text1 != text2) {
				alert (msg);

Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last Edit: 5 years 4 months ago by tpartner.

Please Log in to join the conversation.

Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form