Lock Form Fields and Disable Button

New Here ,
May 25, 2022 May 25, 2022

Copy link to clipboard

Copied

I have set up a "Lock Form Fields" button using custom Javascript off of an older form. 

 

var nButton = app.alert({
    cMsg: "Do you want to lock down and save this document?",
    cTitle: "Form lockdown",
    nIcon: 2, nType: 2});

if ( nButton == 4 ) { 
   for (var i=0; i<this.numFields; i++) {
var fname = this.getNthFieldName(i);
var f = this.getField(fname);
if (f.type!="button" && f.type!="signature") f.readonly = true;}
    app.execMenuItem("SaveAs");
}

 

Is it possible to add javascript to disable the button once it has been clicked? The forms are locked afterwards, but the button remains and I worry less tech-savvy users will continue to click and save thinking it is not locked. Is there a way to make the button non-clickable after the forms have been locked and the document saved?

TOPICS
Create PDFs , Edit and convert PDFs , How to , JavaScript , PDF forms

Views

43

Likes

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 2 Correct answers

Adobe Community Professional , May 25, 2022 May 25, 2022

Select 'Prepare form' tool -> click on 'More' and select 'Document actions' then select 'Document will save' then click 'Edit' and use this script:

this.getField("Button").readonly = true;

Replace "Button" with yur button field name.

This will make that button field readonly when document is saved.

Likes

Translate

Translate
Adobe Community Professional , May 25, 2022 May 25, 2022

In that case disregard above approach and just add this line: event.target.readonly = true; to the end of your script before last }

Likes

Translate

Translate
Adobe Community Professional ,
May 25, 2022 May 25, 2022

Copy link to clipboard

Copied

Select 'Prepare form' tool -> click on 'More' and select 'Document actions' then select 'Document will save' then click 'Edit' and use this script:

this.getField("Button").readonly = true;

Replace "Button" with yur button field name.

This will make that button field readonly when document is saved.

Likes

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 25, 2022 May 25, 2022

Copy link to clipboard

Copied

This worked! Is there a way to add to the script that it only applys if it is saved with the button, not if it is saved regularly?

Likes

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
Adobe Community Professional ,
May 25, 2022 May 25, 2022

Copy link to clipboard

Copied

LATEST

In that case disregard above approach and just add this line: event.target.readonly = true; to the end of your script before last }

Likes

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