Skip to main content
Participant
June 6, 2022
Question

Display number of characters in a text form field

  • June 6, 2022
  • 1 reply
  • 3121 views

I do not know javascript. I thought Adobe had a library of static code to add but, alas, I was mistaken. Issue - I have a form I designed from scratch. Trying to display for the user the following:

 

1. As they type in a field, display the number of characters remaining, and/or

2. Display an error message when trying to exceed the max number of characters for a field.

 

Doesn't seem this should be so difficult. In one of the multitude of threads I read, a user made a good point:  if Adobe Pro is calculating the number of characters being entered in a character constrained field, why can't this be displayed? Duh, Adobe! 

This topic has been closed for replies.

1 reply

Nesa Nurani
Community Expert
Community Expert
June 7, 2022

You can find answer  how to count characters as you type here:

https://answers.acrobatusers.com/Count-characters-q113907.aspx 

Participant
June 9, 2022

I am not clear if I'm adding this script correctly. I went to that thread and saw the following code. Am I just copying and pasting it in the custom keystroke script box? If I do, it's not working. Changed the number of characters of 3000 to 255. I have zero clue what I'm doing. 

if (event.willCommit == false) {
var ec = event.change;
var nv = event.value + ec;
var nc = nv.length;
var msg = nc + " characters typed.\n";
msg += (3000 - nc) + " remaining.";
this.getField("counter").value = msg;
}

Nesa Nurani
Community Expert
Community Expert
June 10, 2022

It will display remaining character in field "counter" do you have that field in your file? If not you should rename it to the field name where you want to show message.