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

Conditional fields

New Here ,
Dec 15, 2022 Dec 15, 2022

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.pngexpand image

TOPICS
How to , PDF forms
285
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 ,
Dec 15, 2022 Dec 15, 2022
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

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