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

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

Community Beginner ,
Apr 11, 2025 Apr 11, 2025

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

TOPICS
How to , JavaScript , PDF forms
112
Translate
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 ,
Apr 11, 2025 Apr 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"});}
Translate
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 ,
Apr 11, 2025 Apr 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)

Translate
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 ,
Apr 11, 2025 Apr 11, 2025
LATEST

Correct.  Typing too fast.

Translate
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