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

Set a MINIMUM Character Limit in a PDF Form Field

Community Beginner ,
Jul 22, 2021 Jul 22, 2021

Copy link to clipboard

Copied

When creating digital forms in Acrobat, I see you can set a Maximum character limit easily when opening the Text Field Properties, then going to the Options Tab to do so. But there's nothing about setting a MINIMUM. I'm not familiar with JavaScript at all, and I saw a post from about 10 years ago talking about this, so I'm sure it's dated to say the least in fixing my issue.

 

Thanks in advance!

TOPICS
How to , JavaScript , PDF forms

Views

3.4K

Translate

Translate

Report

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

correct answers 1 Correct answer

Community Expert , Jul 22, 2021 Jul 22, 2021

If you're OK with the value being validated when the user exits the field (not as they're typing), you can use this code as the custom Validation script for it:

 

var minAllowedChars = 5;
if (event.value.length>0 && event.value.length<minAllowedChars) {
	app.alert("You must enter at least "+minAllowedChars+" characters.");
	event.rc = false;
}

 

 

Votes

Translate

Translate
Community Expert ,
Jul 22, 2021 Jul 22, 2021

Copy link to clipboard

Copied

How would the user be able to fill in the field if there's a minimum limit to the number of characters in it?

Or do you only want to validate it after they leave the field? And should it allow the field to be empty?

Votes

Translate

Translate

Report

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 ,
Jul 22, 2021 Jul 22, 2021

Copy link to clipboard

Copied

If you're OK with the value being validated when the user exits the field (not as they're typing), you can use this code as the custom Validation script for it:

 

var minAllowedChars = 5;
if (event.value.length>0 && event.value.length<minAllowedChars) {
	app.alert("You must enter at least "+minAllowedChars+" characters.");
	event.rc = false;
}

 

 

Votes

Translate

Translate

Report

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 ,
Jul 22, 2021 Jul 22, 2021

Copy link to clipboard

Copied

PS. Nothing much changed in this regard in the last 10 years, maybe even 20. If you found a solution for this issue from 10 years ago it will very likely work now, too. The only thing that might have changed since then is how to arrive to the place where the code should go.

Votes

Translate

Translate

Report

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 Beginner ,
Jul 23, 2021 Jul 23, 2021

Copy link to clipboard

Copied

LATEST

Perfect. Thank you!

Votes

Translate

Translate

Report

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