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

Lock Form Fields and Disable Button

New Here ,
May 25, 2022 May 25, 2022

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
2.6K
Translate
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
2 ACCEPTED SOLUTIONS
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.

View solution in original post

Translate
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

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

View solution in original post

Translate
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

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.

Translate
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

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?

Translate
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

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

Translate
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
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?

Translate
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