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

Conditional fields

New Here ,
Dec 15, 2022 Dec 15, 2022

Copy link to clipboard

Copied

Looking to make a field required based on the answer to a previous field.  I know nothing about Javascript.

I require client to select Married or Single in a dropdown Marital Status field.  Based on their selection in the Marital Status field I want to require them to input Spouse name, Spouse mobile and Spouse email if they select Married in the Marital Status field2022-12-15_15-33-14.png

TOPICS
How to , PDF forms

Views

198

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 ,
Dec 15, 2022 Dec 15, 2022

Copy link to clipboard

Copied

LATEST

The required parameter of a form field doesn't mean anything unless the form is being submitted. You might consider hiding or graying out the spouse field if "single" is selected.

 

This code just sets the required parameters. Place it in the Custom Validation script for the "Martial Status" dropdown 

 

var bUseSpouse = (event.value  == "Married")
this.getField("Spouse name").required = bUseSpouse;
this.getField("Spouse mobile").required = bUseSpouse;
this.getField("Spouse email").required = bUseSpouse;

 

Here's an article on hiding and showing fields 

https://www.pdfscripting.com/public/Hiding-and-Showing-Form-Fields.cfm?sd=40

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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