Skip to main content
August 26, 2016
Question

JavaScript Exception

  • August 26, 2016
  • 2 replies
  • 311 views

Hi there,

I wish to know the extension of the Javasript to make an entire PDF read only Except one button. I currently have the coding that will make the whole document 'read only' however I Wish to have an exception for the 'submit' button.

Please let me know what the code extension to the below is:

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

    var fname = this.getNthFieldName(i);

    this.getField(fname).readonly = true; // makes all fields readonly

     }

This topic has been closed for replies.

2 replies

JR Boulay
Community Expert
Community Expert
August 26, 2016

Hi.

You don't need an exception: just lock all fields, then unlock the button.

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

    var fname = this.getNthFieldName(i);

    this.getField(fname).readonly = true; // makes all fields readonly

    }

this.getField(MYBUTTON).readonly = false;

Acrobate du PDF, InDesigner et Photoshopographe
Inspiring
August 26, 2016

Try this:

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

    var fname = this.getNthFieldName(i);

    if (fname !== "NameOfButtonToExclude") {

        this.getField(fname).readonly = true; // makes all fields readonly

    }

}

but replace "NameOfButtonToExclude" with the actual name of the button you want to exclude.