Welcome, Guest
Username: Password: Remember me

TOPIC: Can I set a minimum charactors/time requirement on long free text questions?

Can I set a minimum charactors/time requirement on long free text questions? 3 years 4 weeks ago #67840

  • anlie
  • anlie's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 3
  • Karma: 0
Can I set a minimum charactors/ time spend requirement on long free text questions? I can only see the maximum charactors/ time limit requirement from the software. Thank you very much!
The administrator has disabled public write access.

Re: Can I set a minimum charactors/time requirement on long free text questions? 3 years 4 weeks ago #67858

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5423
  • Thank you received: 307
  • Karma: 252
For text questions you can only set a maximum number of characters. You should be able to use regular expressions though: docs.limesurvey.org/Using+regular+expres...tions+for+LimeSurvey

Some text questions also support timers (see docs.limesurvey.org/Advanced+question+se...imeSurvey#time_limit), but I think those timers are only used to limit the time, not to check if a certain time was spend. For this you might have to code your own Javascript function.

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.

Re: Can I set a minimum charactors/time requirement on long free text questions? 3 years 4 weeks ago #67879

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4360
  • Thank you received: 827
  • Karma: 381
Here is a JavaScript solution to enforce a minimum number of characters and a minimum elapsed time (in seconds) for a long-text question.


1) Set up your survey to use JavaScript.

2) Add the following script to the source of the long-text question. Replace "QQ" with the long-text question ID, "CC" with the minimum number of characters and "TT" with the minimum number of seconds.

The script interrupts the Next/Submit function and checks for the minimum characters and elapsed time. If either are not met, an alert is displayed and the Next/Submit function is aborted.
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
 
		minCharMinTime(QQ, CC, TT);
 
		function minCharMinTime(qID, minChars, minTime) {
 
			var startTime = new Date();
 
			$('#movenextbtn, #movesubmitbtn').click(function(){
 
				var endTime = new Date();
 
				if($('#question'+qID+' textarea').val().replace(/ /g,'').length < minChars) {
					alert ('You must enter at least '+minChars+' characters.');
					return false;
				}
				else if((endTime - startTime)/1000 <= minTime) {
					alert ('You must spend at least '+minTime+' seconds on the question.');
					return false;
				}
				else {
					return true;
				}
 
				return false;
			});
		}
 
	});
</script>
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Re: Can I set a minimum charactors/time requirement on long free text questions? 3 years 4 weeks ago #67934

  • anlie
  • anlie's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 3
  • Karma: 0
Thank you very much for both of your reply. It's difficult to me. Hope we can have an option like this later.:lol:
The administrator has disabled public write access.

Re: Can I set a minimum charactors/time requirement on long free text questions? 3 years 4 weeks ago #67942

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5423
  • Thank you received: 307
  • Karma: 252
Tony, I heard there is some place left at the workaround wiki page ;-)

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.

Re: Can I set a minimum charactors/time requirement on long free text questions? 3 years 4 weeks ago #67955

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4360
  • Thank you received: 827
  • Karma: 381
Here is the script with a small bug fixed:
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function() {
 
		minCharMinTime(QQ, CC, TT);
 
		function minCharMinTime(qID, minChars, minTime) {
 
			var startTime = new Date();
 
			$('#movenextbtn, #movesubmitbtn').click(function(){
 
				var endTime = new Date();
 
				if($('#question'+qID+' textarea').val().replace(/ /g,'').length < minChars) {
					alert ('You must enter at least '+minChars+' characters.');
					return false;
				}
				else if((endTime - startTime)/1000 <= minTime) {
					alert ('You must spend at least '+minTime+' seconds on the question.');
					return false;
				}
				else {
					return true;
				}
			});
		}
 
	});
</script>
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Re: Can I set a minimum charactors/time requirement on long free text questions? 3 years 4 weeks ago #67958

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4360
  • Thank you received: 827
  • Karma: 381
...I heard there is some place left at the workaround wiki page...

I think it would be rare that both the minimum time and minimum characters would be required so I broke it up into two workarounds:

Minimum elapsed time before moving forward in survey - docs.limesurvey.org/tiki-index.php?page_...ng_forward_in_survey

Minimum number of characters in Long free text or Huge free text questions - docs.limesurvey.org/tiki-index.php?page_..._free_text_questions
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.137 seconds
Donation Image