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

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

575

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

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

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

576

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
Apr 18, 2019 0
Most Valuable Participant ,
Apr 18, 2019

Copy link to clipboard

Copied

Only by hiding the signature field until all the required fields are filled in.

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...
Apr 18, 2019 0
Adobe Community Professional ,
Apr 18, 2019

Copy link to clipboard

Copied

... or setting it to read-only until the required fields are filled.

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...
Apr 18, 2019 0
Community Beginner ,
Apr 24, 2019

Copy link to clipboard

Copied

Hi Joel

How could I set it to read-only until the required fields are filled?

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...
Apr 24, 2019 0
Community Beginner ,
Apr 24, 2019

Copy link to clipboard

Copied

Hi Try67

How could I go about hiding the signature field until all the required fields are completed?

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...
Apr 24, 2019 0
Adobe Community Professional ,
Apr 24, 2019

Copy link to clipboard

Copied

Hi,

Could you not use something like this - Creating a conditional action with multiple required fields

If you set your signature field to hidden or readonly in the UI so when the user opens the document there is no signature field.

The only bit you might want to add to be save is an 'else' to make sure your signature field gets hidden again if the user changes any fields so they are not filled in.

// code shown for hiding and showing a signature field called "mySignatureField".

if(bAllFilled)

{

     this.getField("mySignatureField").display = display.visible;

}

else

{

this.getField("mySignatureField").display = display.hidden;

}

Regards

Malcolm

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...
Apr 24, 2019 0
Community Beginner ,
Apr 24, 2019

Copy link to clipboard

Copied

Hi Malcolm

Thanks for getting back to me. I changed the name of the digital signature field to mySignatureField and added the below script but its not working. Is there something else I need to added to the script?

if(bAllFilled)

{

     this.getField("mySignatureField").display = display.visible;

}

else

{

     this.getField("mySignatureField").display = display.hidden

}

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...
Apr 24, 2019 0
Adobe Community Professional ,
Apr 24, 2019

Copy link to clipboard

Copied

Hi,

you also need the script from the forum post I linked too, my script was just an addition to that script.

Regards

Malcolm

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...
Apr 24, 2019 0
Community Beginner ,
Apr 24, 2019

Copy link to clipboard

Copied

Hi Malcolm

I followed the instructions on the link. I created a hidden field on the form and added the below script but its bringing up an error message?

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"));
}
f.valueAsString==""
0=="";
var aFields = ["Start Date", "Name", "Status", "Job Title","Person Type","HR Manager","Manager","Working Hours","start","Finish","Pro Day","Pro Mont","Note Day","Note Mont","Evac Site","Roster","Softworks Dept","Currency","Salary","Sal Basis","Sal Year","Per","Per F","Company Car","Car Allowance","Fuel Card","Fuel Allowance","PlanType","LocalBonus","Sub Plan","Annual Target","Target Amount","Charged Segment","Healthcare","Local Healthcare","Life Insurance","Overtime","Employee","Employer","Organisation","BU Overide","Department Headcount","Location","Payroll1","Assign Category","Job Code","Apprenticeship","Location120","Account","Cost Centre","Product Line","Interco","Future","dropdown1","dropdown2","dropdown3","Safety","TTMS Module","Non-Majority","Badge/Fob","Internet","Laptop",];

var bAllFilled = true;

for(var i=0;i<aFields.length;i++)

{
    var oFld = this.getField(aFields);
     if(oFld.value == oFld.defaultValue)
     {
          bAllFilled = false;
          break;
      }
}
if(bAllFilled)
{
if(bAllFilled)
{
     this.getField("mySignatureField").display = display.visible;
}
else
{

     this.getField("mySignatureField").display = display.hidden
}

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...
Apr 24, 2019 0
Adobe Community Professional ,
Apr 24, 2019

Copy link to clipboard

Copied

add a } at the end.

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...
Apr 24, 2019 1
Most Valuable Participant ,
Apr 24, 2019

Copy link to clipboard

Copied

There are other issues with the code. Namely, it's an amalgam of two ways of doing it, one that checks all requires fields in the file and one that checks specific fields, defined in a list. It doesn't make sense to use both.

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...
Apr 24, 2019 0
Community Beginner ,
Apr 24, 2019

Copy link to clipboard

Copied

Hi Try67

Forgive me I'm not good with JavaScripts. Which section would you remove?

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...
Apr 24, 2019 0
Most Valuable Participant ,
Apr 24, 2019

Copy link to clipboard

Copied

That depends on how you want it to work...

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...
Apr 24, 2019 0