Skip to main content
Known Participant
May 5, 2016
Question

How do I disable all fields when sending a pdf through the "submit a form" button?

  • May 5, 2016
  • 1 reply
  • 11940 views

I want to make sure that the fillable fields will not be editable when received via email.

Thank you!

This topic has been closed for replies.

1 reply

Karl Heinz  Kremer
Community Expert
May 5, 2016

If this solution needs to work in both Adobe Acrobat and the free Adobe Reader, your only option is to set the fields to read-only in your form. You can do this by running a loop over all fields and then set the "readonly" property to "true":

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

    this.getField(this.getNthFieldName(i)).readonly = true;

}

Depending on how your button is set up, you may have to add two different actions (or add this script to your already existing JavaScript action):

Known Participant
May 5, 2016

That's fantastic. (And forgive me for my lack of knowledge with regard to Adobe Acrobat...I'm learning, but it's going slowly..) The ultimate goal is that the "disabled" form is only disabled when it is sent via email. Now the issue I'm running into is that the code also locks the "reset form" button which is crucial for filling out the document again for a new client.  Any solutions??

Known Participant
May 6, 2016

I can't thank you enough for this help. I wish I had messaged you earlier with this question, but I thought I had it! So, I am trying to use the script above to lock all fields/hide buttons and then I need to email it which should prompt the fields to unhide/unlock (using code above again). However, none of the email/submit scripts that I'm trying are working at all, let alone letting me attach the PDF. Can you help??


This is the code that I'm using...bear in mind that this is my first time to ever ever LOOK at Javascript, so I know it's pretty piecemeal Thank you again.

var emptyFields = [];

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

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

     if (f.type!="button" && f.required ) {

          if ((f.type=="text" && f.value=="") || (f.type=="checkbox" && f.value=="Off")) emptyFields.push(f.name);

     }

}

if (emptyFields.length>0) {

     app.alert("Error! You must fill in the following fields:\n" + emptyFields.join("\n"));

}

else

// The text in a Question Alert Box is usually in two parts.  A short explaination

// and the actual question.  It's a good practice to separate the question from the

// explaination by a line, In the text below, this separation is accomplished

// with the escaped line feed characters "\n\n"

//

// The alert box will only show about 6 lines of text, so both explainations and

// text should be kept short

var cMsg = "Have you confirmed that all fields are complete and accurate?";

cMsg += "\n\n Form will lock upon sending.";

var nRtn = app.alert(cMsg,2,2,"Question Alert Box");

if(nRtn == 4)

{// A yes Response

  // Code for doing the thing you do on a yes

  console.println("The Response Was Yes");

var answer = app.alert("Are you sure you're ready to submit Production Form for quote? ", 2, 2);  

/* Question icon, Yes/No button. */

/* 0 = error, 1 = OK, 2 = Cancel, 3 = No, 4 = Submit Form */

{

}

if (answer == 3)

{

}

if (answer == 4)

{

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

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

          if (f.type != "button") {  

              f.readonly = true;  

         } 

         else {

              f.display = display.hidden;

         }

    }  }

var Subject_Line = getField("New Construction Door Production Form").value

var Subject_Line2 = getField("Customer Name").value

    this.mailDoc({

        cTo: "mailto:user@domain.com",

        cSubject: Subject_Line+"_"+Subject_Line2,

         cMsg: "Quote requested: New Construction Exterior Door. Thank you!"

    });

}

else if(nRtn == 3)

{ // No Response

  console.println("The Response Was No");

}

else 

{ //Unknown Response

  console.println("The Response Was somthing other than Yes/No: " + nRtn);

}