Password protect field (not secured)
I would like to password protect a specific field. I just want to prevent clients from entering data in the field, except for a specific few. It does not have to be secure, if people end up adding data to the field it is not the end of the world, just annoying. I have this so far, which seems to be working for the alert message however, when I enter the password, the field does not switch to allowing me to enter data into it. Not sure if it is possible to have the field switch from read only to editable when the correct password is entered. Here is what I have so far:
(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., "PRIV.NAME")
var f_prefix = "MCC#";
// 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
if (f.readonly) {
var resp = app.response({
cQuestion: "To unlock the fields, enter the password:",
cTitle: "Enter password",
bPassword: true,
cLabel: "Password"
});
} else {
var resp = pw;
}
})();
Any help is much appreciated! Thanks!
