Auto populate fields with 'N/A' when signature field is completed
Copy link to clipboard
Copied
Hi All,
I need some script help from the community!
I have a PDF form being used as part of a filling process operation. In short, the operators populate a field with data, then electronically sign next to the data. The signature then locks the field and makes it a read only.
On occasion it is required for the operator to leave a field blank as it is not applicable ... but what I would like to is if there is a way for the blank field to be automatically populated with 'N/A' when the signature is applied if the field is left blank?
Thanks in advanced. !
Copy link to clipboard
Copied
You can place this script as a "Mouse enter" action in the signature field:
var oFld = this.getField("nameOfTheField");
if (oFld.value == oFld.defaultValue) {oFld.value = "N/A";}
Acrobate du PDF, InDesigner et Photoshoptographe
Copy link to clipboard
Copied
JR Boulay, that would apply "N/A" before field is signed.
Perhaps it would be better to use 'On Blur' so it apply when field is signed, and you could use something like this:
var fields = ["Text A","Text B","Text C"];
for(var i in fields){
if(this.getField(fields[i]).valueAsString == "")
this.getField(fields[i]).value = "N/A";}
Replace "Text A","Text B","Text C" with your actual field names and you can easily add more names to it.
Copy link to clipboard
Copied
This has worked! Thank you so much!
Copy link to clipboard
Copied
Does this work when the user cancel the signing?
Copy link to clipboard
Copied
If user cancel signing and click outside sign field it will still populate fields with "N/A" which is probably what OP doesn't want.
If that would happen then it is better to use script under signed tab, if OP wants to set all fields to read-only after signing then he can use this:
var fields = ["Text A","Text B","Text C"];
for(var i in fields){
if(this.getField(fields[i]).valueAsString == "")
this.getField(fields[i]).value = "N/A";}
for (var j=0; j<this.numFields; j++){
this.getField(getNthFieldName(j)).readonly=true;}
If he wants some of the fields set to read only he can use this (changing/adding actual field names to variable 'fields' and 'fields2' where 'fields2' are fields to be set read-only) :
var fields = ["Text A","Text C"];
for(var i in fields){
if(this.getField(fields[i]).valueAsString == "")
this.getField(fields[i]).value = "N/A";}
var fields2 = ["Text field name","Checkbox field name","Button field name"];
for(var j in fields2){
this.getField(fields2[j]).readonly=true;}
Copy link to clipboard
Copied
You can execute a script when the field is signed:
Copy link to clipboard
Copied
In that case he would need to implement read only part to the script also since he probably already using 'Mark as read-only'.

