Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

How to make the comment mandatory?

More
9 years 3 weeks ago #127241 by Perry
How to make the comment mandatory? was created by Perry
The question type is "list with comment"

After set mandatory in question, still can't force the participant to fill comment field.

Any solutions?
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team & Official Partner
  • LimeSurvey Community Team & Official Partner
More
9 years 3 weeks ago #127245 by DenisChenu
Replied by DenisChenu on topic How to make the comment mandatory?
Hi,

In the last version : you have "Question validation equation". If your question code is QCODE : put !is_empty(QCODE_comment) in this setting.

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.
The topic has been locked.
More
9 years 3 weeks ago - 9 years 3 weeks ago #127247 by Perry
Replied by Perry on topic How to make the comment mandatory?
Awesome!!! Thanks a lot!

Could you send me you BTC or BTS account?

Added the expression like this [!is_empty(Q2a_comment) or (Q2a.NAOK == "1") or (Q2a.NAOK == "2")]
It looks well.

Final style like this: the mandatory comment shows when chosen NAOK3 or NAOK4, while the comment will auto hided and non-mandatory when chosen NAOK1 or NAOK2.

//When I use "!is_empty(Q2a_comment)", it worked.
//However it's failed when expression is [if((Q2a.NAOK == "3" or Q2a.NAOK == "4"),!is_empty(Q2a_comment),"")]

//I want the mandatory comment shows when chosen NAOK3 or NAOK4, while the comment will auto hided and non-mandatory when chosen //NAOK1 or NAOK2.

//Hereafter is the auto hided code:
Code:
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
// Identify this question
  var thisQuestion = $('#question{QID}');
 
// start listener
  $('input.radio', thisQuestion).on('click', function(e) {
      if($(this).attr('value') >2 ) {
        $('p.answer-item',thisQuestion).show();
      }
      else {
        $('p.answer-item',thisQuestion).hide();
      }
  });
 
});
</script>
.
Last edit: 9 years 3 weeks ago by Perry.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team & Official Partner
  • LimeSurvey Community Team & Official Partner
More
9 years 3 weeks ago #127248 by DenisChenu
Replied by DenisChenu on topic How to make the comment mandatory?
The comment hide/shown can not be done using Expression.

But here : the expression must be:
Code:
(Q2a.NAOK>2 AND !is_empty(Q2a_comment.NAOK))
OR
(Q2a.NAOK<=2 AND is_empty(Q2a_comment.NAOK))

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.
The topic has been locked.
More
9 years 3 weeks ago - 9 years 3 weeks ago #127249 by Perry
Replied by Perry on topic How to make the comment mandatory?
Sure, I used the expression like [!is_empty(Q2a_comment) or (Q2a.NAOK == "1") or (Q2a.NAOK == "2")]
And it worked!
Besides I pasted the JS script to show/hide comment in above posts.

Thanks a lot for your kindly and rapid answer.

Send your BTC or BTS account to me , please.
Last edit: 9 years 3 weeks ago by Perry.
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose