Skip to main content
EventeReporting
Participant
Feb 25, 2016 2:37 AM UTC
Answered

Disabling the paste function in a text field

I am creating a PDF form and am wanting to restrict the user so they cannot paste text from another source into a text field on the form.  Is this possible?

I am using Acrobat Pro DC.

Thanks.

This topic is closed to new replies. Start a new post to keep the conversation going.
George_JohnsonCorrect answer
Inspiring
Feb 25, 2016 6:01 AM UTC

The custom keystroke script (Text Field Properties dialog > Format tab > Custom format category > Custom Keystroke Script) can be as simple as:

event.rc = event.change.length < 2;

The problem is if you need to do this for fields that use one of the built-in formatting categories (e.g., Number or Date), then it gets more complicated.

12 replies

Participant
Oct 1, 2024 2:51 PM UTC

It worked. However if I open the form with a browser, pasting text in the field is allowed. Any suggestions?

 

Translate
try67
Community Expert
Community Expert
Oct 1, 2024 4:24 PM UTC

There's nothing to do about it. Most browser PDF plugins are sub-par when it comes to scripts and form fields.

You can complain to the developers of these plugins, but the real solution is to instruct the users to open the file in Reader if they want it to work correctly.

Translate
Participant
Oct 1, 2024 4:30 PM UTC

Is there a way to ensure that the PDF file only opens in Adobe Acrobat?

Note: For reference, Firefox is currently the only browser that maintains keystroke restrictions.

Translate
Inspiring
Feb 25, 2016 5:38 AM UTC

In a keystroke script you can reject anything that's more than a single character, as would happen if multiple characters were pasted. This would still allow the user to paste a single character at a time. Would that be OK?

Translate
EventeReporting
Participant
Feb 25, 2016 5:40 AM UTC

If that is something I can setup easily that would be fine.

Thanks.

Translate
George_JohnsonCorrect answer
Inspiring
Feb 25, 2016 6:01 AM UTC

The custom keystroke script (Text Field Properties dialog > Format tab > Custom format category > Custom Keystroke Script) can be as simple as:

event.rc = event.change.length < 2;

The problem is if you need to do this for fields that use one of the built-in formatting categories (e.g., Number or Date), then it gets more complicated.

Translate