Check out the LimeSurvey source code on GitHub!
Welcome, Guest
Username: Password:

TOPIC: Making comment box mandatory for List With Comment question type

Making comment box mandatory for List With Comment question type 2 years 8 months ago #106520

  • maxersloan
  • maxersloan's Avatar
  • Offline
  • Premium Lime
  • Posts: 37
  • Karma: 0
Does anyone know of a way to make the comment box mandatory? The question type I am using is "List With Comment." I thought this would be simple/easy task, but I can't find answers anywhere (yet!).
The administrator has disabled public write access.

Making comment box mandatory for List With Comment question type 2 years 8 months ago #106570

  • first
  • first's Avatar
  • Offline
  • Platinum Lime
  • Posts: 329
  • Thank you received: 35
  • Karma: 15
Past below code in question text source.If it will not work then give me survey link and question ID.

<script>
$(document).ready(function(){
$errorDiv = $('<br><div class = "errormandatory"></div>')
$('span.questionhelp:eq(0)').append($errorDiv)
$('button#movenextbtn').click(function(){
if($('textarea').val().trim() == "" ){
$('div.errormandatory').text('Please provide comment in box')
return false;
}
});
});
</script>
Survey Designer and Programmer
"I always suggest to have a group by group display layout and create a seprate group for each question. This will be extra work but you will get flexiblity to create your question by using more than more lime survey question types."
Last Edit: 2 years 8 months ago by first. Reason: typo
The administrator has disabled public write access.
The following user(s) said Thank You: AGK925

Making comment box mandatory for List With Comment question type 2 years 2 months ago #112970

  • AGK925
  • AGK925's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 16
  • Thank you received: 2
  • Karma: 0
trivender wrote:
Past below code in question text source.If it will not work then give me survey link and question ID.

<script>
$(document).ready(function(){
$errorDiv = $('<br><div class = "errormandatory"></div>')
$('span.questionhelp:eq(0)').append($errorDiv)
$('button#movenextbtn').click(function(){
if($('textarea').val().trim() == "" ){
$('div.errormandatory').text('Please provide comment in box')
return false;
}
});
});
</script>

I know this is old so I hope you might still be able to help me. I tried the code you provided and it seems to work expect the error message "Please provide comment in box" shows on the first question on the page and not the question this relates to. Thank you.
The administrator has disabled public write access.

Making comment box mandatory for List With Comment question type 2 years 2 months ago #112993

  • first
  • first's Avatar
  • Offline
  • Platinum Lime
  • Posts: 329
  • Thank you received: 35
  • Karma: 15
I can help but I would need a link to a test survey with the question where you want to use this code.
Survey Designer and Programmer
"I always suggest to have a group by group display layout and create a seprate group for each question. This will be extra work but you will get flexiblity to create your question by using more than more lime survey question types."
The administrator has disabled public write access.

Making comment box mandatory for List With Comment question type 2 years 2 months ago #113001

  • AGK925
  • AGK925's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 16
  • Thank you received: 2
  • Karma: 0
Thank you for your quick response, but I was able to correct the problem by changing

$('span.questionhelp:eq(0)').append($errorDiv)

to

$('span.questionhelp:eq(4)').append($errorDiv)
The administrator has disabled public write access.
Time to create page: 1.200 seconds
Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form