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

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

1.2K

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

Community Expert , 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.

Votes

Translate

Translate
Community Expert , 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 }

Votes

Translate

Translate
Community Expert ,
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.

Votes

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?

Votes

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

Copy link to clipboard

Copied

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

Votes

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 ,
Sep 11, 2022 Sep 11, 2022

Copy link to clipboard

Copied

LATEST

Is it possible to trigger the save as BEFORE the lock occurs? IE - if they click cancel on the save as pop up, it will not lock the form?

Votes

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