Hide all fillable form buttons with a password
Hi all,
I have not long started using JavaScript in my fillable forms, I have found the below script online that locks all fillable fields after a button is pressed & a password is entered correctly
(function() {
// Prefix for group field names. Change to match what you want to use.
// Rename the fields you want to lock to match this prefix (e.g., "SITE.NAME")
var f_prefix = "SITE";
// Your chosen password goes here
var pw = "1234";
// Get a reference to the first field in the group
var f = getField(f_prefix).getArray()[0];
//Determine new readonly state, which is the opposite of the current state
var readonly = !f.readonly;
var readonly_desc = readonly ? "lock" : "unlock";
//Prompt user for the password
var resp = app.response({
cQuestion: "To" + readonly_desc + "the fields, enter the password:",
cTitle: "Enter password",
bPassword: true,
cLabel: "Password"
});
switch (resp) {
case pw:
getField(f_prefix).readonly = readonly;
app.alert("The fields are now " + readonly_desc + "ed.", 3);
break;
case null: // User pressed Cancel button
break;
default: // Incorrect password
app.alert("Incorrect password.", 1);
break;
}
})();
I would like to do the same to hide all buttons on the form when a button is pressed & a correct passwords is entered, all I have found so far is the below script to hide the buttons which works as it should but no password option.
for (var i=0; i<this.numFields; i++) {
var f = this.getField(this.getNthFieldName(i));
if (f==null) continue;
if (f.type=="button") f.display = display.hidden;
}
Would it be possible to add making the buttons on the form hidden to the original script I am using, if not add a password option to the script to hide the buttons?
Also, can it be set up so the buttons don't print either?
Any help would be appreciated
Thanks in advance
