Welcome to the LimeSurvey Community Forum

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

Character Limit for 'Other' Option

  • BBCMResearch
  • BBCMResearch's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
7 years 11 months ago #134861 by BBCMResearch
Character Limit for 'Other' Option was created by BBCMResearch
Hi,

I have a couple of multiple choice questions in my survey that have "Other" Options at the end. My client wants these options to be limited to no more than 150 characters, however I can't figure out where/if I can set a character limit.

Advice?
The topic has been locked.
More
7 years 11 months ago #135042 by first
Replied by first on topic Character Limit for 'Other' Option
jsfiddle.net/pioul/ysC7L/

I little google search is always helpful...

Survey Designer and Programmer
The following user(s) said Thank You: BBCMResearch
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 11 months ago #135070 by tpartner
Replied by tpartner on topic Character Limit for 'Other' Option
You can add something like this to the question source:

Code:
<script type="text/javascript" charset="utf-8">    
  $(document).ready(function() {
    $('#question{QID} input.text').attr('maxlength', '150');
  });
</script>

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: BBCMResearch, nique
The topic has been locked.
  • BBCMResearch
  • BBCMResearch's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
7 years 11 months ago #135089 by BBCMResearch
Replied by BBCMResearch on topic Character Limit for 'Other' Option
Thank you both!
The topic has been locked.
More
6 years 11 months ago #153380 by nique
Replied by nique on topic Character Limit for 'Other' Option
Apologies for asking this on an old thread, but is it possible to add this to a List - Other option?

I have used the other script for Multiple choice questions and it works great! But it does not appear to work for a dropdown list.

Thanks in advance for any help.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 11 months ago #153407 by tpartner
Replied by tpartner on topic Character Limit for 'Other' Option
Try this:

Code:
<script type="text/javascript" charset="utf-8">    
  $(document).ready(function() {
    $('#question{QID} input[type="text"]').attr('maxlength', '150');
  });
</script>

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: nique
The topic has been locked.
More
6 years 11 months ago #154147 by nique
Replied by nique on topic Character Limit for 'Other' Option
Thank you! Works a treat.

Am I correct in assuming that this - [type="text"] - identifies the specific Other text input?
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 11 months ago #154167 by tpartner
Replied by tpartner on topic Character Limit for 'Other' Option
Yes, the [type="text"] selector will target all short-text inputs in that question. Those inputs normally have an associated class "text" (used in the previous workaround) but that class seems to have been omitted in this question type.

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: nique
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 9 months ago #156914 by DenisChenu
Replied by DenisChenu on topic Character Limit for 'Other' Option
To be sure it woirk without javascript (never trust user):
Code:
strlen(Multi_other.NAOK) < 150
in em_validation_q manual.limesurvey.org/Question_type_-_Mu...28em_validation_q.29

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.
More
3 years 10 months ago - 3 years 10 months ago #200276 by reginab
Replied by reginab on topic Character Limit for 'Other' Option
Sorry added in duplicate by mistake
Last edit: 3 years 10 months ago by reginab.
The topic has been locked.
More
3 years 10 months ago - 3 years 10 months ago #200277 by reginab
Replied by reginab on topic Character Limit for 'Other' Option
Hi,
I have tried this out but can't seem to get it working, I wonder would you mind taking a look?
Here is my question:(see Capture1.png)
It is called q313_other (see Capture2.png)
Here is the code I added:(see Capture3.png)
However I can add more than 4 chars (see Capture4.png)



Any help would be much appreciated

Thanks,
R
Last edit: 3 years 10 months ago by reginab.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 10 months ago #200279 by tpartner
Replied by tpartner on topic Character Limit for 'Other' Option
Change:
Code:
input.text

To:
Code:
input[type="text"]

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose