• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Signature completes and then required fields identified

Explorer ,
Jun 12, 2019 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

444

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
community guidelines
Community Expert ,
Jun 12, 2019 Jun 12, 2019

Copy link to clipboard

Copied

You must check the fields before signing the document.

Votes

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
community guidelines
Explorer ,
Jun 12, 2019 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.

Votes

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
community guidelines
Community Expert ,
Jun 12, 2019 Jun 12, 2019

Copy link to clipboard

Copied

You can add the code to a form button.

Votes

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
community guidelines
Explorer ,
Jun 12, 2019 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.

Votes

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
community guidelines
Community Expert ,
Jun 13, 2019 Jun 13, 2019

Copy link to clipboard

Copied

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

Votes

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
community guidelines
Explorer ,
Jun 13, 2019 Jun 13, 2019

Copy link to clipboard

Copied

LATEST

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 ;

}

}

Votes

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
community guidelines