Signature completes and then required fields identified

Community Beginner ,
Jun 12, 2019

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.value == null)

{

error = error + requiredFields + '\n';

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"});

TOPICS
Acrobat SDK and JavaScript, Windows

Views

170

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Signature completes and then required fields identified

Community Beginner ,
Jun 12, 2019

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.value == null)

{

error = error + requiredFields + '\n';

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"});

TOPICS
Acrobat SDK and JavaScript, Windows

Views

171

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jun 12, 2019 0
Adobe Community Professional ,
Jun 12, 2019

Copy link to clipboard

Copied

You must check the fields before signing the document.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 12, 2019 0
Community Beginner ,
Jun 12, 2019

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 12, 2019 0
Adobe Community Professional ,
Jun 12, 2019

Copy link to clipboard

Copied

You can add the code to a form button.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 12, 2019 0
Community Beginner ,
Jun 12, 2019

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 12, 2019 0
Adobe Community Professional ,
Jun 13, 2019

Copy link to clipboard

Copied

Checking the required fields after signing the document makes no sense.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 13, 2019 0
Community Beginner ,
Jun 13, 2019

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.value == null)

{

error = error + requiredFields + '\n';

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 ;

}

}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 13, 2019 0