Expand my Community achievements bar.

Single field password protected?

Avatar

Former Community Member
Is there anyway to make a single text field password protected rather than the whole form? I need some areas of my form to be locked but not the entire thing.



Thanks in advance!
9 Replies

Avatar

Former Community Member
Unfortunately, there's no way of password-protecting a single field within a PDF document. Only the PDF document as a whole can be password-protected. There are ways of
simulating something being password protected with script but this wouldn't give you the encryption protection that password-protected PDF documents have.



Stefan

Adobe Systems

Avatar

Former Community Member
What about associating particular fields within a subform to a signature? I want to be able to route it electronically without having subsequent reviewers change previously entered data.

Avatar

Former Community Member
Unfortunately, you can't do that either. You can only sign the entire document. I can say, however, that the ability to sign specific fields on a form is a feature that has been requested by many other customers.



Stefan

Adobe Systems

Avatar

Level 10
Hi,



For what it is worth, here is some script that may be able to mimic what you want - I know this is not password protected, however it will allow you to input two fields (or however many you require), protect them and then forward the form to other Users, who will not be able to amend these fields. The following javascript is based on protecting two fields ("Mytext1" and "MyDate"), which are set within the form to "Read Only".



The "Exit" Event of a Check Box named Protect is as follows:

if (this.rawValue == 0) {

Mytext1.access = "open";

MyDate.access = "open";

Protect.access = "open";

Protect.presence = "visible";

}

else {

Mytext1.access = "readOnly";

MyDate.access = "readOnly";

Protect.access = "readOnly";

Protect.presence = "invisible";

}



However you also need to set the "Layout:Ready" event of the same Check Box named "Protect" as follows:

if (this.rawValue == 0) {

Mytext1.access = "open";

MyDate.access = "open";

}

if (this.rawValue == 1) {

Protect.presence = "invisible";

}



On this basis, if you open the form and the "My" fields are blank, then the check box is available to the User to select protection of the fields. However if the fields are not null and protected, then when the USer opens the file they will remain protected.



Once the data is inputted into the "My" fields, then the originator of the form selects the Check Box. When the check box is exited, then the fields are protected and the Check Box is made invisible.



I think that the form could be set up with a signature field to protect individual fields, however I have not been able to achieve this. This is one way in setting up a form, so that on each occasion you want to issue it, you can input the two fields you require, select the check box and then issue it.



Hope this helps.



Regards,



Niall

Avatar

Level 10
Mea culpa, mea culpa, mea maxima culpa (I'm sorry, I'm sorry, I'm very sorry).



Natalie, since posting the thread, there have been some comments as to why put the script on the Exit Event of the Checkbox. Stefan has suggested a better solution: By hiding the checkbox and incorporating a button instead, which the User click and pushes a command to the checkbox. The script from Stefan is as follows (Note Button name = "Protect" and hidden (invisible) Checkbox name = "Lock"):



b CLICK EVENT of Button "Protect":



if (Mytext1.rawValue != null && Mytext1.rawValue.length > 0 && MyDate.rawValue != null && MyDate.rawValue.length > 0)

{

// "lock" the fields

Mytext1.access = "readOnly";

MyDate.access = "readOnly";



// save value of lock

Lock.rawValue = "1";



// make the lock button disappear after some time

app.setTimeOut("this.getField('form1[0].#subform[0].Protect[0]').hidden = true;", 1000);

}

else

{

app.alert("Please enter data in both fields prior to locking them.");

}



(I particularly like the inclusion of the app.Alert)



b READY:LAYOUT EVENT of Button "Protect":



if (Lock.rawValue == "0")

{

Mytext1.access = "open";

MyDate.access = "open";

}

else

{

Protect.presence = "invisible";

}



Keep the faith: Stefan solutions are better, in that they allow for the User to select a button, which is cleaner. In addition the App.Alert ensures that the fields are completed before they are locked (in a relatively insecure way).



In coming up with this work around I have used the following Adobe forum threads and Stefan's & StevenX's help:



http://www.adobeforums.com/cgi-bin/webx/.3bbfacee/0



Goodnight, Niall

Avatar

Former Community Member
Thanks for posting those updates, Niall.



I didn't suggest such a solution myself when I originally replied to this thread because it was asking about signing a field in order to protect it. Since signing a field would imply that data integrity would have to be conserved throughout the form's workflow, I couldn't suggest a solution similar to Niall's as a viable alternative. Even though the fields are set to "readOnly" once you check the check box, there's nothing preventing malicious script (like an Acrobat plug-in, for example) from modifying the field's value and therefore the solution doesn't guarantee the data integrity guaranteed with a digital signature. Once a form is signed, it becomes encrypted in such a way that is supposed to ensure that it can no longer be modified by any means. Being able to sign a single field would require Acrobat to be able to encrypt a single field on a form while still letting it's value be queried so as not to break calculations on the form which may depend on the signed field's value. This isn't a feature available in Designer 7.x and Acrobat 7.x. Fortunately, I can say that the ability to sign a specific set of fields on a form is something we've been working on but I can't make promises...



By this I don't mean to say that Niall's solution isn't a good one. I simply want to post a
word of caution because the alternative solution here does
not guarantee data integrity. If you feel that simply setting a field to read-only is enough to meet your requirements, then Niall's solution should work just fine for you.



Stefan

Adobe Systems

Avatar

Former Community Member
At Niall's request, here's the sample form created by Niall which includes my suggestions/modifications to use a button with an invisible check box where clicking the button will immediately set the fields to read-only if they've been filled. When the fields are set to read-only, the invisible check box's value is set to "1" (checked) so that the form "remembers" the lock state for the fields the next time the form is opened (buttons don't have values which get saved but check boxes do...).



One thing to note: My solution makes use of the app.setTimeOut method in order to hide the button about 1 second after it has been pressed. Code which executes within the app.setTimeOut method executes within the context of the Acrobat Document Scripting Object which means that "this" refers to the Acrobat Document Object. From there, you access a field by giving a specific SOM expressing to the Document Object's getField method and you have to use methods and properties on the Acrobat Field Scripting Object to hide the field.



To get a feel for the solution, fill the two fields at the top and then click the button. The fields will become read-only with a gray background. Save the form, close it and re-open it. At this point, the fields will have the data you last entered and won't be editable and the button won't be visible.



If you would like me to go into more detail, just let me know.



Stefan

Adobe Systems

Avatar

Former Community Member
I hate to resurrect such an old thread, but I need help! I am basically using this example to create a similar lock on one field. I downloaded the template provided by Stefan above, and it works fine, yet when I add it to my form, the button no longer disappears using the app.setTimeOut method as defined in the code. The strange thing is, if I copy the fields and button from the document above into a new document, it will stop working correctly. What's the deal?



Thanks.