- Posts: 3
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Hide the Next Button Until a Particular Character/Word Count is Achieved
- TreyBrasher
- Topic Author
- Offline
- New Member
Less
More
4 years 9 months ago #185786
by TreyBrasher
Hide the Next Button Until a Particular Character/Word Count is Achieved was created by TreyBrasher
In order to get a deep response, I would like to code a question so that the 'next' button will not appear until a minimum character/word count is reached. I have very little coding experience but spent the last few hours trying to piece together code other people have written to first hide the 'next' button, and then display it again after the character count is reached. The code I attempted is attached. It is written in the question code. My skill level is obviously not up to snuff and I cannot find a solution in the forum. Please help! Thanks in advance.
Attachments:
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10098
- Thank you received: 3589
4 years 9 months ago #185790
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Hide the Next Button Until a Particular Character/Word Count is Achieved
LimeSurvey version?
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- TreyBrasher
- Topic Author
- Offline
- New Member
Less
More
- Posts: 3
- Thank you received: 0
4 years 9 months ago #185792
by TreyBrasher
Replied by TreyBrasher on topic Hide the Next Button Until a Particular Character/Word Count is Achieved
3.17.5
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10098
- Thank you received: 3589
4 years 9 months ago - 4 years 9 months ago #185811
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Hide the Next Button Until a Particular Character/Word Count is Achieved
You need (among other things) to incorporate a listener on the textarea. (adjust the minCharacters variable as required)
Sample survey attached:
Code:
<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:scriptcomplete',function(){ // Identify this question var thisQuestion = $('#question{QID}'); var thisTextArea = $('textarea:eq(0)', thisQuestion); // Set minimum characters var minCharacters = 10; function handleCharacterCount() { var thisVal = $.trim($(thisTextArea).val()); var thisCount = thisVal.length; $('.character-count', thisQuestion).text(thisCount); if(thisCount <= minCharacters) { $('#ls-button-submit').prop('disabled', true); } else { $('#ls-button-submit').prop('disabled', false); } } // Initial state handleCharacterCount(); // Listener on the textarea $(thisTextArea).on('keyup change', function(e) { handleCharacterCount(); }); }); </script>
Sample survey attached:
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
Last edit: 4 years 9 months ago by tpartner.
The following user(s) said Thank You: cdorin
The topic has been locked.
- TreyBrasher
- Topic Author
- Offline
- New Member
Less
More
- Posts: 3
- Thank you received: 0
4 years 9 months ago #185846
by TreyBrasher
Replied by TreyBrasher on topic Hide the Next Button Until a Particular Character/Word Count is Achieved
Wow, works perfectly. Your work is very much appreciated, I thank you deeply. Can't wait to conduct some research with this survey!
The topic has been locked.