Skip to main content
Known Participant
May 5, 2016
Question

How do I disable all fields when sending a pdf through the "submit a form" button?

  • May 5, 2016
  • 1 reply
  • 11940 views

I want to make sure that the fillable fields will not be editable when received via email.

Thank you!

This topic has been closed for replies.

1 reply

Karl Heinz  Kremer
Community Expert
Community Expert
May 5, 2016

If this solution needs to work in both Adobe Acrobat and the free Adobe Reader, your only option is to set the fields to read-only in your form. You can do this by running a loop over all fields and then set the "readonly" property to "true":

for (var i=0; i<this.numFields; i++) {

    this.getField(this.getNthFieldName(i)).readonly = true;

}

Depending on how your button is set up, you may have to add two different actions (or add this script to your already existing JavaScript action):

Known Participant
May 5, 2016

That's fantastic. (And forgive me for my lack of knowledge with regard to Adobe Acrobat...I'm learning, but it's going slowly..) The ultimate goal is that the "disabled" form is only disabled when it is sent via email. Now the issue I'm running into is that the code also locks the "reset form" button which is crucial for filling out the document again for a new client.  Any solutions??

Karl Heinz  Kremer
Community Expert
Community Expert
May 6, 2016

I tried that and it's keeping the active "clear form" and "submit" buttons in the email, meaning the recipient can use them. Is it simply re-ordering the list? I'm so grateful for you help - thank you.


What you have to do is change the status of these fields before you run the "Submit a form" action - in the same script that you set the other form fields to readonly. You've used this script (it's the same from above) to filter out buttons and set the other fields to readonly:

for (var i=0; i<this.numFields; i++) { 

     var f = this.getField(this.getNthFieldName(i)); 

     if (f.type != "button") { 

          f.readonly = true

     } 

}

If you change the criteria and look for fields that are buttons, you can set these to display.hidden. And, because of the features of JavaScript, we don't have to write a new loop, we can actually use the same loop and the same test, just use the "else" branch of the if statement:

for (var i=0; i<this.numFields; i++) { 

     var f = this.getField(this.getNthFieldName(i)); 

      if (f.type != "button") { 

          f.readonly = true

     }

     else {

          f.display = display.hidden;

     }

}

Again, to reverse this after the form is submitted, you set readonly to true and you set display to display.visible.