Skip to main content
Inspiring
July 22, 2021
Answered

Set a MINIMUM Character Limit in a PDF Form Field

  • July 22, 2021
  • 1 reply
  • 5828 views

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!

This topic has been closed for replies.
Correct answer try67

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;
}

 

 

1 reply

try67
Community Expert
Community Expert
July 22, 2021

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?

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
July 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;
}

 

 

try67
Community Expert
Community Expert
July 22, 2021

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.