Skip to main content
Participant
February 9, 2018
Answered

Using a radio button on a form to not allow a user to enter text in a text field

  • February 9, 2018
  • 2 replies
  • 3376 views

Hi I am creating a form and if the user selects the YES radio button, they do not have to answer questions 4, 5 or 6... how do I lock out those text fields so that they can not input answers?

This topic has been closed for replies.
Correct answer Thom Parker

You'll need a script on the radio button to disable the fields in question.

The easy solution is to place a script like this on the MouseUp of the radio button that disables the other fields

this.getField("Q4").readOnly = true;

this.getField("Q5").readOnly = true;

this.getField("Q6").readOnly = true;

You'll need to opposite script on the other radio buttons.

You'll find a fancier solution (for graying out the fields) here:

https://acrobatusers.com/tutorials/js_disabling_fields

2 replies

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
February 16, 2018

You'll need a script on the radio button to disable the fields in question.

The easy solution is to place a script like this on the MouseUp of the radio button that disables the other fields

this.getField("Q4").readOnly = true;

this.getField("Q5").readOnly = true;

this.getField("Q6").readOnly = true;

You'll need to opposite script on the other radio buttons.

You'll find a fancier solution (for graying out the fields) here:

https://acrobatusers.com/tutorials/js_disabling_fields

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
try67
Community Expert
Community Expert
February 16, 2018

For fields this property is called "readonly". For annotations it's "readOnly"...

Thom Parker
Community Expert
Community Expert
February 16, 2018

Thanks Gilad, I always get those mixed up

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
AkanchhaS8194121
Legend
February 16, 2018

Hi Gymnstxnut,

If I got your query correctly, I assume that you are referring this to all the user? Or are you taking about locking the feature for one particular user?

Because this can be achieved by turning those particular form's filed as "Read-Only" which is shared with all the users by following the steps mentioned below-

Open Form using Adobe Acrobat>Tools>Prepare Form> Select Form filed and right click on it>Properties>General> check "Read-Only" as shown in picture below-

those particular filed would be locked.

If you are referring this property to be disabled for one particular user, then for that you have to take help of script that should be applied for that one user.

Regards,
Akanchha