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

How do you disable fields in PDF form?

New Here ,
May 23, 2019 May 23, 2019

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
17.3K
Translate
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
1 ACCEPTED SOLUTION
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");

View solution in original post

Translate
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

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");

Translate
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

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!

Translate
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

Post your code.

Translate
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

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?

Translate
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

Sorry, my bad. It needs to be:

for (var i in fields)

Translate
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

This worked! Amazing thank you!

Translate
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

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

Translate
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

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

What does the error message say, exactly?

Translate
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

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

Translate
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

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

Translate
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

Check the double quotes. Use only "

Translate
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
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

Translate
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