- Posts: 60
- Thank you received: 1
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Making comment box mandatory for List With Comment question type
- maxersloan
- Topic Author
- Offline
- Senior Member
Less
More
10 years 1 month ago #106520
by maxersloan
Making comment box mandatory for List With Comment question type was created by maxersloan
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 topic has been locked.
- first
- Offline
- Elite Member
Less
More
- Posts: 227
- Thank you received: 36
10 years 1 month ago - 10 years 1 month ago #106570
by first
Survey Designer and Programmer
Replied by first on topic Making comment box mandatory for List With Comment question type
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>
<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
Last edit: 10 years 1 month ago by first. Reason: typo
The following user(s) said Thank You: AGK925
The topic has been locked.
- AGK925
- Offline
- New Member
Less
More
- Posts: 16
- Thank you received: 3
9 years 6 months ago #112970
by AGK925
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.
Replied by AGK925 on topic Making comment box mandatory for List With Comment question type
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 topic has been locked.
- first
- Offline
- Elite Member
Less
More
- Posts: 227
- Thank you received: 36
9 years 6 months ago #112993
by first
Survey Designer and Programmer
Replied by first on topic Making comment box mandatory for List With Comment question type
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
The topic has been locked.
- AGK925
- Offline
- New Member
Less
More
- Posts: 16
- Thank you received: 3
9 years 6 months ago #113001
by AGK925
Replied by AGK925 on topic Making comment box mandatory for List With Comment question type
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)
$('span.questionhelp:eq(0)').append($errorDiv)
to
$('span.questionhelp:eq(4)').append($errorDiv)
The topic has been locked.
- Dickdolus
- Offline
- New Member
Less
More
- Posts: 1
- Thank you received: 0
7 years 2 months ago #147718
by Dickdolus
Replied by Dickdolus on topic Making comment box mandatory for List With Comment question type
Skittles1123 07-29-2014 at 2:49 AM
he/she may like you this really works!try it out!
1.say your name 10x
2.say your moms name 5x
3.say your crushes name 3x
4.then paste this to 4 other quizes,if you do your crush will kiss you on the nearest friday!but if you dont youll have bad luck
he/she may like you this really works!try it out!
1.say your name 10x
2.say your moms name 5x
3.say your crushes name 3x
4.then paste this to 4 other quizes,if you do your crush will kiss you on the nearest friday!but if you dont youll have bad luck
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13633
- Thank you received: 2491
7 years 2 months ago #147723
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Making comment box mandatory for List With Comment question type
I really think it's better to use Expression Manager here : then : no workaround : work out of the box, when updating LS too + PHP control done.
Usage of : manual.limesurvey.org/Question_type_-_Li...28em_validation_q.29
em_validation_q : !is_empty(self.sq_comment)
em_validation_q_tip : Comment is mandatory
Usage of : manual.limesurvey.org/Question_type_-_Li...28em_validation_q.29
em_validation_q : !is_empty(self.sq_comment)
em_validation_q_tip : Comment is mandatory
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.