Expand my Community achievements bar.

Allowing user to set password for form?

Avatar

Level 4

I have a performance evaluation form that has been rights-extended so users can save data typed into the form, but the users would like to be able to set their own passwords for security purposes. Is there any way to do this? My last resort I guess will be to just tell them to zip the pdf file into a password protected zip file, but I feel like there must be a way to script something in the doc:ready event??

Thanks,

Jo

9 Replies

Avatar

Level 4

Ok, maybe one of the gurus here can help me work throught what I've got so far.

https://acrobat.com/#d=n7VWB0Ft*H-h3S1sMVN65g

This file works the way I want the first time you save it with a password, but when you reopen it, everything is hidden. Can anyone tell me where I'm going wrong here? I think this will be great if I can just tweak the details a little.

Thanks!

Jo

Avatar

Level 10

Hi,

I designed a sample to protect a form with a password.

Therefore I use 2 hidden fields somewhere in the form that store either the password and the state of the form (protected or unprotected).

The I added two script, one in the preSave:event one in the docReady:event.

The preSave script check if the form state is set to unprotected (0), if so it opens a response box to enter a password, that is stored in the hidden password field.

After that the form fields are set to invisible and the form is saved.

When the form is reopend the docReady script check if the form state is set to protected (1).

If so, it asks for the password.

If the password is wrong or empty the form fields stay invisible.

The preSave:event script:

if (xfa.resolveNode("#pageSet.Master.Protected").rawValue == "0")

     {

     var pw = xfa.host.response("Enter Password", "Enter Password", "", true);

     if (pw != null)

          {

          xfa.resolveNode("#pageSet.Master.PW").rawValue = pw;

          xfa.resolveNode("#pageSet.Master.Protected").rawValue = "1";

          Form1.Page.presence = "invisible";

          }

     }

The docReady:event script

if (xfa.resolveNode("Form1.#pageSet.Master.Protected").rawValue != "0")

     {

     var chk = xfa.host.response("Password required", "Password required", "", true);

     var pw = xfa.resolveNode("Form1.#pageSet.Master.PW").rawValue;

     this.presence = chk === pw? "visible":"invisible";

     }

https://acrobat.com/#d=BKSKrGZKs0uYhWozbw0GUQ

Avatar

Level 4

Thanks! This works really well, but is there a way to just leave the password blank, in case the user doesn't want to or need to password

protect the form?

Jo


Edit: I now see that you can just click Cancel to leave it unprotected. When I click cancel in Adobe Pro, the JavaScript Debugger pops up:

Acrobat JavaScript Debugger Functions Version 9.0
Acrobat EScript Built-in Functions Version 9.0
Acrobat Annotations / Collaboration Built-in Functions Version 9.0
Acrobat Annotations / Collaboration Built-in Wizard Functions Version 9.0
Acrobat SOAP 9.0

SyntaxError: missing ; before statement
8:Document-Level:!ADBE::0100_VersChkStrings
xfa.event.cancelAction is not a function
12:XFA:Form1[0]:preSave
TypeError: xfa.event.cancelAction is not a function
12:XFA:Form1[0]:preSave
xfa.event.cancelAction is not a function
12:XFA:Form1[0]:preSave
TypeError: xfa.event.cancelAction is not a function
12:XFA:Form1[0]:preSave
xfa.event.cancelAction is not a function
12:XFA:Form1[0]:preSave
TypeError: xfa.event.cancelAction is not a function
12:XFA:Form1[0]:preSave
xfa.event.cancelAction is not a function
12:XFA:Form1[0]:preSave
TypeError: xfa.event.cancelAction is not a function
12:XFA:Form1[0]:preSave
xfa.event.cancelAction is not a function
12:XFA:Form1[0]:preSave
TypeError: xfa.event.cancelAction is not a function
12:XFA:Form1[0]:preSave
xfa.event.cancelAction is not a function
12:XFA:Form1[0]:preSave
TypeError: xfa.event.cancelAction is not a function
12:XFA:Form1[0]:preSave
xfa.event.cancelAction is not a function
12:XFA:Form1[0]:preSave
TypeError: xfa.event.cancelAction is not a function
12:XFA:Form1[0]:preSave

I can't find the java error, but would an Adobe Reader user even see this?

Avatar

Level 10

Oh, this was a code fragment in the sample.

I removed it.

You can enter a password or cancel to save the form unprotected.

Avatar

Level 4

I think this is going to work great if I can just get it to work in my form. I'm still getting the javascript debugger popping up, but I don't think Adobe Reader users will get that anyway and it doesn't make it unfunctional.

Thank you!

Jo

Avatar

Level 10

Please redownload the sample!

I made a little change.

if (xfa.resolveNode("#pageSet.Master.Protected").rawValue == "0")

     {

     var pw = xfa.host.response("Enter Password", "Enter Password", "", true);

     if (pw != null && pw != "")

          {

          xfa.resolveNode("#pageSet.Master.PW").rawValue = pw;

          xfa.resolveNode("#pageSet.Master.Protected").rawValue = "1";

          Form1.Page.presence = "invisible";

     }

}

Avatar

Level 4

I never could get it to work in my form, so I just copied my form onto yours and now it works great! haha Where there's a will....

Thank you for the great script!

Jo

Avatar

Level 2

Hi radzmar

i there way to see the form you did this in?...

Im trying to do the same thing in my form

Thanks

bruce

Avatar

Level 10

Hmmm,

the thread is almost 3 years old, but you're lucky that the link sample is still online.

https://acrobat.com/?d=BKSKrGZKs0uYhWozbw0GUQ