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

How do you disable fields in PDF form?

New Here ,
May 23, 2019 May 23, 2019

Copy link to clipboard

Copied

I have a complex 40 page PDF document with a form on each page. At top of each form/page is a 'not required' check box. Is there a way to set this so that if the user selects 'not required' they can TAB straight to next page/form without having to TAB through the form below that isn't required to be filled in?

TOPICS
PDF forms

Views

15.8K

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 , May 24, 2019 May 24, 2019

Yes, you can use a script to set all the fields on the page as read-only when the check-box is ticked.

The basic code to do it (as the MouseUp event of the check-box) would be something like this:

var fields = ["Field1", "Field2", "Field3"]; // replace with actual field names

for (var i fields) this.getField(fields).readonly = (event.target.value!="Off");

Votes

Translate

Translate
Community Expert ,
May 24, 2019 May 24, 2019

Copy link to clipboard

Copied

Yes, you can use a script to set all the fields on the page as read-only when the check-box is ticked.

The basic code to do it (as the MouseUp event of the check-box) would be something like this:

var fields = ["Field1", "Field2", "Field3"]; // replace with actual field names

for (var i fields) this.getField(fields).readonly = (event.target.value!="Off");

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
New Here ,
May 24, 2019 May 24, 2019

Copy link to clipboard

Copied

Thank you, have tried the script but can't get it to work unfortunately. I keep getting syntax error message saying missing an ; but it is there!

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 ,
May 24, 2019 May 24, 2019

Copy link to clipboard

Copied

Post your code.

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
New Here ,
May 24, 2019 May 24, 2019

Copy link to clipboard

Copied

var fields = ["Assets description 4", "Assets description 5", "Assets description 6"]; for (var i fields) this.getField(fields).readonly = (event.target.value!="Off"); 

I'm most likely being an idiot here sorry, do I need to fill in the other other bracket info?

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 ,
May 24, 2019 May 24, 2019

Copy link to clipboard

Copied

Sorry, my bad. It needs to be:

for (var i in fields)

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
New Here ,
May 24, 2019 May 24, 2019

Copy link to clipboard

Copied

This worked! Amazing 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
New Here ,
May 24, 2019 May 24, 2019

Copy link to clipboard

Copied

Sorry to bother you again but I also have several check boxes in this section that I need to bypass as well as fields. I tried entering into your script above but they won't work (error message). Do I need to do a seperate script for this and substitute the word fields for check boxes? Thanks Kelly

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 ,
May 24, 2019 May 24, 2019

Copy link to clipboard

Copied

Check-boxes are form fields, so it should work just fine.

What does the error message say, exactly?

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
New Here ,
May 24, 2019 May 24, 2019

Copy link to clipboard

Copied

That's what I thought as well. I get a SyntaxError: missing ] after element list 1: at line 2

var fields = [“Dependants 1 name", "Dependants 1 relationship", "Dependants 1 DOB", "Dependants 1 age", "Dependents 1 living at home”, "Special needs 1”]; for (var i in fields) this.getField(fields).readonly = (event.target.value!="Off");

Dependents 1 living at home' and 'special needs' are check boxes. If I delete these, the error message goes

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 ,
May 24, 2019 May 24, 2019

Copy link to clipboard

Copied

You have to only use straight quotes, not curly ones. Do not edit the code in Word! Use a plain-text editor, only.

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 ,
May 24, 2019 May 24, 2019

Copy link to clipboard

Copied

Check the double quotes. Use only "

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 ,
May 28, 2019 May 28, 2019

Copy link to clipboard

Copied

LATEST

The readOnly property only makes the fields refuse input from the user. It doesn't let the user know the field is disabled.

Here is an article and example file on giving fields a disabled look.

https://acrobatusers.com/tutorials/js_disabling_fields

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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