This script limits the number of characters typed into an Open End text box.
Note:
- This script only works on desktop and for surveys in English. If you require this on mobile also, it can be used in conjunction with an additional validation script - click here.
- This script works only if participants have Javascript enabled on their browsers.
Example
Detailed Steps
- Copy the script below.
- Select the question in the Questionnaire Tree.
- In the Scripting section of the question, click Edit Scripts.
- Paste the script into JavaScript tab.
- Change Q_NAME to your open-end question name.
- Change ### to the number of maximum characters you want to limit responses to. e.g. 150
- Click Save.
- Optional - Add # characters remaining label
- Select the open end question.
- Copy and paste the following line into the question text area.
<span class="remainingCharacters"></span> characters remaining.
- Optional - If you require more than one open-end question on a Page and would like to display the character limiter for each question, simply copy the line of script below and paste it just after where you see /* more open-ends add after this */ in the script.
var v2 = new limiter('[%(Q_NAME.Id)%]', ###).init();
Repeat step 5 - 6. Notice the number in red. This number should be incremented for additional open-end questions included in a Page such as v3, v4, and so on. - Click Save.
- Validate and test your survey.
Script
<script src="https://static.visioncritical.net/prog/ext_libs/jquery/jquery-1.12.3.min.js" type="text/javascript"></script> <script src="https://static.visioncritical.net/prog/s1/js/common/common_v1.6.js" type="text/javascript"></script> <script> /* Script Name: How do I add a character counter limiter to an open end text box? To ensure your script works as expected, always copy the original script from the script library found in the support portal. Failure to use the most up to date script from the script library may cause unexpected results. */ var v1 = new limiter('[%(Q_NAME.Id)%]', ###).init(); /* more open-ends add after this */ </script>
If you need to limit the number of characters on mobile, please follow steps here.
More Information
Read this WebHelp article to learn more about Open End question.
Comments
0 comments
Article is closed for comments.