Skip to main content
Known Participant
March 24, 2020
Question

Do not allow digital signature until all required fields not blank

  • March 24, 2020
  • 2 replies
  • 3231 views

We are working on implementing digital signatures on forms due to our recent inability to meet directly with our customers. From what I read it seems I need to have a button that would unhide the digital signature field if it was checked and that would run a script to check if all of the required fields were not blank, if one was still blank it would alert the user they need to fill out all required fields. Can someone please help me with this script? I have tried but I am not able to get it to work correctly.

2 replies

try67
Community Expert
Community Expert
March 25, 2020

You can use this code to do it:

 

this.getField("Signature").readonly = !validateRequiredFields(this);

function validateRequiredFields(doc) {
	var emptyFields = [];
	for (var i=0; i<doc.numFields; i++) {
		 var f = doc.getField(doc.getNthFieldName(i));
		 if (f!=null && f.type!="button" && f.required && f.valueAsString==f.defaultValue) {
			emptyFields.push(f.name);
		}
	}

	if (emptyFields.length>0) {
		 app.alert("You must fill in the following fields:\n" + emptyFields.join("\n"));
		 return false;
	}
	return true;
}	
Known Participant
March 25, 2020

Thanks a bunch, but where exactly does this go?

try67
Community Expert
Community Expert
March 25, 2020

As the Mouse Up event of your button.

ls_rbls
Community Expert
Community Expert
March 24, 2020

Hi,

 

Please share the script that you're trying to use so that the developers in the forums can assist you better.

Known Participant
March 24, 2020

Thanks for the reply, I don't think anything i had found was too helpful. 
Basically any required fields blank then signature is not allowed. 

Known Participant
March 25, 2020

I got the bottom to work but now I want a popup to display a message that not all required fields are filled out if they click the read only signture box otherwise it is confusing

 

if(event.value != "" && this.getField("Last Name").value != "" && this.getField("First Name").value != ""
&& this.getField("Street Address").value != ""
&& this.getField("City").value != ""
&& this.getField("Zip").value != ""
&& this.getField("Phone number").value != ""
&& this.getField("Date_of_Birth").value != ""
&& this.getField("Sex").value != ""
this.getField("Signature").readonly = false;
} else {
this.getField("Signature").readonly = true;
}