Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


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

111

Likes

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

Adobe Community Professional , 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; }

Likes

Translate

Translate
Adobe Community Professional ,
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?

Likes

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
Adobe Community Professional ,
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;
}

 

 

Likes

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
Adobe Community Professional ,
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.

Likes

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!

Likes

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