Copy link to clipboard
Copied
I am trying to create a form. My goal is to have the form lock itself when a specific text box (not signature) is completed. Is there a way to do this?
Create a button field and as its Mouse Up event have it run the following JavaScript code:
if (app.alert("Are you sure you want to finalize the file?",2,2)==4) {
if (app.viewerType=="Reader") {
for (var i=0 ; i<this.numFields ; i++) {
var f = this.getField(this.getNthFieldName(i)) ;
if (f==null) continue;
if (f.type=="button" || f.type=="signature") continue;
f.readonly = true;
f.defaultValue = f.valueAsString;
}
} else {
this.flattenPages();
}
}
Copy link to clipboard
Copied
You can achieve that with a JavaScript script.
Do you intend to keep that field lock after it is completed or do you intend to give the user an option to revert the field to unlock if other conditions are met?
Copy link to clipboard
Copied
Thank you! I intend to keep it locked, I believe.
Essentially, I need to create a form where person A completes the form as fully as possible and once done, emails it to person B. Once it is edited to person B's standards, they complete the specific field and when they save, the entire form becomes locked/read-only.
Copy link to clipboard
Copied
A digital signature is the best way to do that. Any other form of "locking" can easily be reversed, if someone is willing to do so and has access to the right tools.
Copy link to clipboard
Copied
I don't mind if it can be reversed, that would be fine. It doesn't need to be locked for safety. I'm just looking to make it read-only when completed.
Copy link to clipboard
Copied
Then you can do it using this script:
if (app.viewerType=="Reader") {
for (var i=0 ; i<this.numFields ; i++) {
var f = this.getField(this.getNthFieldName(i)) ;
if (f==null) continue;
if (f.type=="button" || f.type=="signature") continue;
f.readonly = true;
f.defaultValue = f.valueAsString;
}
} else {
this.flattenPages();
}
Copy link to clipboard
Copied
Thank you!!! Forgive my ignorance as I'm very new to this world. How do I add this in?
Copy link to clipboard
Copied
What do you want to trigger this? You wrote that it should happen when a specific text box is completed, but I would recommend you reconsider that. What if someone makes a mistake and wants to change it later on? The fields would already have been locked and they couldn't do it...
I would recommend using a button, instead. You can even add a confirmation dialog to the code, to make sure they want to finalize the file.
Copy link to clipboard
Copied
A button would work great as well! Any guidance for that would be great too.
Copy link to clipboard
Copied
Create a button field and as its Mouse Up event have it run the following JavaScript code:
if (app.alert("Are you sure you want to finalize the file?",2,2)==4) {
if (app.viewerType=="Reader") {
for (var i=0 ; i<this.numFields ; i++) {
var f = this.getField(this.getNthFieldName(i)) ;
if (f==null) continue;
if (f.type=="button" || f.type=="signature") continue;
f.readonly = true;
f.defaultValue = f.valueAsString;
}
} else {
this.flattenPages();
}
}
Copy link to clipboard
Copied
YES! Worked perfectly. Thank you so, so much.
Copy link to clipboard
Copied
Be aware that if this is used in Acrobat the process is not reversible, though.