Skip to main content
Participant
April 11, 2025
Question

Javascript: Validate that fields are filled prior to allowing form submission.

  • April 11, 2025
  • 1 reply
  • 330 views

I have a fillable form with two signature fields (BonaFideNeedSig and FundApproverSig) that both must be completed before the user is allowed to submit the form via email.

 

I envisioned a single javascript that executed upon "mouse up" on the Submit button. I think that in order to have the "submit" function depend on the signature fields being filled, the "submit" function needs to be built into an if statement in the javascript (as opposed to just using the generic "submit a form" action in the drop-down).

 

I think the pieces I need are mostly in this old thread but I can't figure out how to put it together for my use case: JavaScript Validation to Submit Form 

 

I've also seen this as an example which maskes sense to me, but I don't have a sufficient grasp of javascript syntax to flesh it out for my situation. Any help would be appreciated! Thank you.

 

var condition1 = ...;

var condition2 = ...;

var condition3 = ...;

if (condition1 && condition2 && condition3) this.mailDoc({cTo: "me@server.com"});

else app.alert("You must first do X, Y and Z before submitting the form.",1);

1 reply

PDF Automation Station
Community Expert
Community Expert
April 11, 2025

if(this.getField("BonaFideNeedSig").signatureValidate()==0 || this.getField("FundApproverSig").signatureValidate()==0)
{app.alert("You must first do X, Y and Z before submitting the form.",1)}
else
{this.mailDoc({cTo: "me@server.com"});}

Corrected by @try67 :

if(this.getField("BonaFideNeedSig").signatureValidate()==0 || this.getField("FundApproverSig").signatureValidate()==0)
{app.alert("You must first do X, Y and Z before submitting the form.",1)}
else
{this.mailDoc({cTo: "me@server.com"});}
try67
Community Expert
Community Expert
April 11, 2025

You forgot the parentheses after signatureValidate, since it's a method, not a property...

First line should be:

if (this.getField("BonaFideNeedSig").signatureValidate()==0 || this.getField("FundApproverSig").signatureValidate()==0)

PDF Automation Station
Community Expert
Community Expert
April 12, 2025

Correct.  Typing too fast.