Copy link to clipboard
Copied
My form has required fields and I want to identify blanks before applying the electronic signature and then emailing.
I need the JS to work in the following order
1. Check for blank required fields
2. If complete apply signature and then save the file
3. Prompt emailing the document
I am using the following Java Script in the Digital Signature Properties under the Signed tab.
The end user will use DC reader.
Thanks for the help.
var requiredFields = new Array();
for (var i = 0; i < this.numFields; i++)
{
var fName = this.getNthFieldName(i);
var f = this.getField(fName);
if (f.type!="button" && this.getField(fName).required && (this.getField(fName).value == null || this.getField(fName).value == ''))
{
requiredFields[requiredFields.length] = fName;}}
var error = "Please complete the following fields: \n\n";
for (j=0; j < requiredFields.length; j++)
{
if (requiredFields
{
error = error + requiredFields
var f2 = this.getField(requiredFields
f2.setFocus();
}
}
if(requiredFields.length > 0)
app.alert(error);
for(var i=0;i<this.numFields;i++)
{
var cFldName = this.getNthFieldName(i);
var oFld = this.getField(cFldName);
if(oFld.required && (oFld.defaultValue == oFld.value))
{
app.alert("Field " + cFldName + " is empty");
}
}
for (var i = 0 ; i < this.numFields ; i++) {
var f = this.getField(this.getNthFieldName(i)) ;
if (f.type!= "signature") //
{
f.readonly = true ;
}
}
this.mailDoc({cTo:"", cSubject: "Purchase Request", cMsg: "Please review and electronically Sign Document"});
Copy link to clipboard
Copied
You must check the fields before signing the document.
Copy link to clipboard
Copied
Sorry, but I need a little more help, I am fairly new to Java script. How do I get the fields checked prior to signature? Whats the forcing function? Otherwise people will submit incomplete documents.
Copy link to clipboard
Copied
You can add the code to a form button.
Copy link to clipboard
Copied
Is there a way to have that button hidden after the signature. That might work, I was just hoping to have it all triggered by the signature.
Copy link to clipboard
Copied
Checking the required fields after signing the document makes no sense.
Copy link to clipboard
Copied
I created the button to validate the required fields. I would like to hide the signature field and make it visible when all the required fields have been validated. What do I need to add and where do I need to add it to the below JS?
Thanks you
var requiredFields = new Array();
for (var i = 0; i < this.numFields; i++)
{
var fName = this.getNthFieldName(i);
var f = this.getField(fName);
if (f.type!="button" && this.getField(fName).required && (this.getField(fName).value == null || this.getField(fName).value == ''))
{
requiredFields[requiredFields.length] = fName;}}
var error = "Please complete the following fields: \n\n";
for (j=0; j < requiredFields.length; j++)
{
if (requiredFields
{
error = error + requiredFields
var f2 = this.getField(requiredFields
f2.setFocus();
}
}
if(requiredFields.length > 0)
app.alert(error);
for(var i=0;i<this.numFields;i++)
{
var cFldName = this.getNthFieldName(i);
var oFld = this.getField(cFldName);
if(oFld.required && (oFld.defaultValue == oFld.value))
{
app.alert("Field " + cFldName + " is empty");
}
}
for (var i = 0 ; i < this.numFields ; i++) {
var f = this.getField(this.getNthFieldName(i)) ;
if (f.type!= "signature") //
{
f.readonly = true ;
}
}