Skip to main content
rafaelvieira553
Participating Frequently
October 11, 2018
Question

How do I lock the fields on a page?

  • October 11, 2018
  • 2 replies
  • 1566 views

Hello, help me please.

We have an electronic form with several pages and the same is populated by several people, I would like you to lock the fields on each page or select the desired field with a JS on a button.

I know the JS that locks every form.

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

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

    if (f==null) continue; 

    f.readonly = true; 

Att,

Rafael Albino

This topic has been closed for replies.

2 replies

try67
Community Expert
Community Expert
October 15, 2018

If you want to lock just the fields on the first page, for example, change this line:

f.readonly = true;

To:

if (f.page==0) f.readonly = true;

rafaelvieira553
Participating Frequently
October 24, 2018

Thank you.

I'm using script like this.

var w = this.getField("buttonX");

w.display = display.hidden;

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

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

if (f==null) continue;

if (f.page==0) f.readonly = true;

}

I wish I had an alert with to confirm the operation.

Yes or no ?

Bernd Alheit
Community Expert
Community Expert
October 11, 2018

You can check the property page of the field.

rafaelvieira553
Participating Frequently
October 15, 2018

As well? Could you please explain.

Bernd Alheit
Community Expert
Community Expert
October 15, 2018

The page property is documented in the Acrobat JavaScript Reference.