Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Display number of characters in a text form field

New Here ,
Jun 06, 2022 Jun 06, 2022

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! 

TOPICS
How to , JavaScript , PDF forms
2.8K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 07, 2022 Jun 07, 2022

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

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 09, 2022 Jun 09, 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;
}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 09, 2022 Jun 09, 2022
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines