Copy link to clipboard
Copied
Is it possible to add a Javascript so that a user cannot digitally sign unless all required fields are completed?
Copy link to clipboard
Copied
May be that you must change your code.
Copy link to clipboard
Copied
I'll need to see the actual file to be able to help you with it.
Copy link to clipboard
Copied
Thanks guys,
I have shared the file via https://drive.google.com/open?id=1Z3I46k8ZaUxbPPexIOSJnUb7EPe0aQ18
When the user selects the confirm button its only the required fields I need to be completed prior to adding their signature?
Copy link to clipboard
Copied
You need to change the code to what I posted earlier.
Copy link to clipboard
Copied
Hi Try67
In the confirm button script I added the below bold and underlined script. At the beginning and at the end.
The script isn't working now. Did I add the script to wrong field or add or did I mess up the script?
if (this.getField("mySignatureField").value==nu)
{ var emptyFields = [];
var emptyFields = [];
for (var i=0; i<this.numFields; i++) {
var f= this.getField(this.getNthFieldName(i));
if (f.type!="button" && f.required ) {
if ((f.type=="text" && f.valueAsString=="") || (f.type=="checkbox" && f.value=="Off")) emptyFields.push(f.name);
}
}
if (emptyFields.length>0) {
app.alert("Error! You must fill in the following fields:\n" + emptyFields.join("\n"));
this.getField("mySignatureField").display = display.hidden
}
else
{
this.getField("mySignatureField").display = display.visible;
} }
Copy link to clipboard
Copied
No, you've made a mess of it... Try this:
if (this.getField("mySignatureField").value==null) {
var emptyFields = [];
for (var i=0; i<this.numFields; i++) {
var f= this.getField(this.getNthFieldName(i));
if (f.type!="button" && f.required && f.valueAsString==f.defaultValue) {
emptyFields.push(f.name);
}
}
if (emptyFields.length>0) {
app.alert("Error! You must fill in the following fields:\n" + emptyFields.join("\n"));
this.getField("mySignatureField").display = display.hidden
} else {
this.getField("mySignatureField").display = display.visible;
}
}
Copy link to clipboard
Copied
Sorry, I tried coping and pasting the below code?
if (this.getField("mySignatureField").value==null) {
var emptyFields = [];
for (var i=0; i<this.numFields; i++) {
var f= this.getField(this.getNthFieldName(i));
if (f.type!="button" && f.required && f.valueAsString==f.defaultValue) {
emptyFields.push(f.name);
}
}
if (emptyFields.length>0) {
app.alert("Error! You must fill in the following fields:\n" + emptyFields.join("\n"));
this.getField("mySignatureField").display = display.hidden
} else {
this.getField("mySignatureField").display = display.visible;
}
}
Copy link to clipboard
Copied
Its not working?
Copy link to clipboard
Copied
You're asking?
Copy link to clipboard
Copied
Sorry I when I enter the below script it doesn't work. Nothing happens when I hit the confirm button?
if (this.getField("mySignatureField").value==null) {
var emptyFields = [];
for (var i=0; i<this.numFields; i++) {
var f= this.getField(this.getNthFieldName(i));
if (f.type!="button" && f.required && f.valueAsString==f.defaultValue) {
emptyFields.push(f.name);
}
}
if (emptyFields.length>0) {
app.alert("Error! You must fill in the following fields:\n" + emptyFields.join("\n"));
this.getField("mySignatureField").display = display.hidden
} else {
this.getField("mySignatureField").display = display.visible;
}
}
Copy link to clipboard
Copied
Change the first line to:
if (this.getField("mySignatureField").value=="") {
Copy link to clipboard
Copied
Thank you Try67, that seems to have done the trick.