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

Is it possible to add a Javascript so that a user cannot digitally sign unless all required fields are completed?

Community Beginner ,
Apr 18, 2019 Apr 18, 2019

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?

TOPICS
Acrobat SDK and JavaScript , Windows

Views

1.5K

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 ,
May 22, 2019 May 22, 2019

Copy link to clipboard

Copied

May be that you must change your code.

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 ,
May 22, 2019 May 22, 2019

Copy link to clipboard

Copied

I'll need to see the actual file to be able to help you with it.

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
New Here ,
May 24, 2019 May 24, 2019

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?

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 ,
May 24, 2019 May 24, 2019

Copy link to clipboard

Copied

You need to change the code to what I posted earlier.

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
New Here ,
May 24, 2019 May 24, 2019

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; 

} }

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 ,
May 24, 2019 May 24, 2019

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;

    }

}

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
New Here ,
May 24, 2019 May 24, 2019

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

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
New Here ,
May 24, 2019 May 24, 2019

Copy link to clipboard

Copied

Its not working?

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 ,
May 24, 2019 May 24, 2019

Copy link to clipboard

Copied

You're asking?

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
New Here ,
May 24, 2019 May 24, 2019

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;

}

}

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 ,
May 24, 2019 May 24, 2019

Copy link to clipboard

Copied

Change the first line to:

if (this.getField("mySignatureField").value=="") {

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
New Here ,
May 24, 2019 May 24, 2019

Copy link to clipboard

Copied

LATEST

Thank you Try67, that seems to have done the trick.

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