Welcome to the LimeSurvey Community Forum

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

Hide "This Question is mandatory" after start typing

  • cmnxyz
  • cmnxyz's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 10 months ago #184169 by cmnxyz
Hey Guys,


i have the following Problem: I have a mandatory free text question. When I dont answer the free text and wanna continue to next page the standard message is displayed: "This question needs to be answered." So far, so good.


When i begin to answer the question the message "This question needs to be answered." is still displayed, which might distract users. So i want to hide this message as soon as users start to type.

Is there any chance to do this on runtime?

Thank you! :)

The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 10 months ago #184222 by tpartner
Disable AJAX mode in the survey theme options and add this script to the question source:

Code:
<script type="text/javascript" charset="utf-8">
 
  $(document).on('ready pjax:scriptcomplete',function(){
 
    // Listener on the input
    $('#question{QID} input:text').on('keyup change', function(e) {
      if($.trim($(this).val()) != '') {
        $('#question{QID} .ls-question-mandatory.text-danger').hide();
      }
    });
 
  });
</script>

Sample survey attached:

File Attachment:

File Name: limesurvey...3312.lss
File Size:13 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: cdorin, cmnxyz
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose