Limit the number of characters in a text field

"How can I limit the Text area field to a preset number of characters?"

You can limit the number of characters from a given text area field, you can consider using the following Javascript snippet (use it in the CSS and Javascript section from the Form's Properties).

You will only have to change the value "textarea" with the name of the Text Area field from your form and add the following line in the field's description:

<script type="text/javascript">
function rslimitText(limitNum){
    //optional line of code to display the remaining characters, if you do not need it, you can remove it completely;
    document.getElementById('length').innerHTML = limitNum - document.getElementById('textarea').value.length;
      if (document.getElementById('textarea').value.length >= limitNum) {
        document.getElementById('textarea').value = document.getElementById('textarea').value.substring(0, limitNum);

You can even add a counter for how many characters remain to be inserted, you only need to add the following lines in the Description of the field:

  <span id="length"></span>

A good trigger for the above mentioned function is the "onkeyup" event. You can add it in the field's Additional Attributes tab as presented here:


6 persons found this article helpful.

Was this article helpful?

Yes No
Sorry about that