Enabling action button on password

New Here ,
May 04, 2022 May 04, 2022

Copy link to clipboard

Copied

Hoping someone can help me with a specific requirement I have. I have included an action button in my pdf to make certain fields in my form read only. I have written the javascript code for it and it works perfectly. I need to include a second action button that would reverse the 'read-only' fields back to being eidtable but this second button should be executed only on a successful password entry. Can someone please help with the javascript code that is required for this second button?

 

Thank you!

TOPICS
How to , JavaScript , PDF forms

Views

89

Likes

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 1 Correct answer

Adobe Community Professional , May 04, 2022 May 04, 2022

Try this script (don't forget to set the password and the name of the field to be unlocked):

 

var cResponse = app.response({cQuestion: "Enter password", cTitle: "PASSWORD", });
{
// Cancel
if (cResponse == null) {app.alert({cMsg: "You must enter your password to unlock this field.", cTitle: "PASSWORD", nIcon: 3});}
// password OK
else if (cResponse == "123456") {this.getField("lockedField").readonly = false;}
// password KO
else {app.alert({cMsg: "Invalid password.", cTitle: "PASSWORD", nIcon: 0});}
}

Likes

Translate

Translate
Adobe Community Professional ,
May 04, 2022 May 04, 2022

Copy link to clipboard

Copied

Try this script (don't forget to set the password and the name of the field to be unlocked):

 

var cResponse = app.response({cQuestion: "Enter password", cTitle: "PASSWORD", });
{
// Cancel
if (cResponse == null) {app.alert({cMsg: "You must enter your password to unlock this field.", cTitle: "PASSWORD", nIcon: 3});}
// password OK
else if (cResponse == "123456") {this.getField("lockedField").readonly = false;}
// password KO
else {app.alert({cMsg: "Invalid password.", cTitle: "PASSWORD", nIcon: 0});}
}

Likes

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 04, 2022 May 04, 2022

Copy link to clipboard

Copied

@JR Boulay Thank you! It worked perfectly! 🙂

Likes

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
Adobe Community Professional ,
May 04, 2022 May 04, 2022

Copy link to clipboard

Copied

LATEST

Keep in mind that this is a very low security level since the password is stored in the script.

Likes

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