Difference between revisions of "Maximum text length"

From Catglobe Wiki
Jump to: navigation, search
(Code)
Line 1: Line 1:
== Challenge ==  
+
== Maximum text length  ==
You want to set maximum length on text question
+
 
== Code ==  
+
In order to limit number of characters that respondent input to text box.
<source lang="javascript" line="1" >
+
 
quest.maxlength = 2
+
As a questionnaire creator
</source>
+
 
 +
I want to set maximum length on text question.
 +
 
 +
'''Example'''
 +
 
 +
*I have a Text grid question like below.
 +
 
 +
[[Image:MaximumTextLength1.jpg]]
 +
 
 +
*I want to set maximum text length.
 +
 
 +
[[Image:MaximumTextLength2.jpg]]
 +
 
 +
=== Solution  ===
 +
 
 +
*Add a Text grid question to Questionnaire editor like below
 +
*Go to menu Properties -&gt; Question scripts -&gt; Java script tab -&gt; Input script
 +
[[Image:MaximumTextLength Code.jpg]]
 +
 
 +
=== Code ===
 +
 
 +
<source lang="javascript">
 +
quest.maxlength = 10;
 +
</source>  
 +
 
 +
=== Source  ===
 +
 
 +
Questionnaire Resource Id on cg site: 159730

Revision as of 10:58, 16 January 2012

Maximum text length

In order to limit number of characters that respondent input to text box.

As a questionnaire creator

I want to set maximum length on text question.

Example

  • I have a Text grid question like below.

MaximumTextLength1.jpg

  • I want to set maximum text length.

MaximumTextLength2.jpg

Solution

  • Add a Text grid question to Questionnaire editor like below
  • Go to menu Properties -> Question scripts -> Java script tab -> Input script

MaximumTextLength Code.jpg

Code

quest.maxlength = 10;

Source

Questionnaire Resource Id on cg site: 159730