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

Required Field if another Field is Filled in.

New Here ,
Nov 03, 2016 Nov 03, 2016

Below is my current script.  However only one field need to be filled out for AVG.  So when first filling out the text box I want to require all the blow fields but if text is put in to AVG.1 the JANAVG1 is not required and vise versa. If text entered into JANAVG.1 then AVG.1 is not required.

if (event.target.value != "") {

    this.getField("BNT.1").required = true;

    this.getField("BIDT.1").required = true;

    this.getField("AVG.1").required = true;

    this.getField("JANAVG.1").required = true;

    }

if (event.target.value == "") {

    this.getField("BNT.1").required = false;

    this.getField("BIDT.1").required = false;

    this.getField("AVG.1").required = false;

    this.getField("JANAVG.1").required = false;

    }

I attempted adding the below to the text field of the AVG.1 and JANAVG.1 however when clearing the form these below commands keep the AVG.1 and JANAVG.1 as required when they are not.

On the AVG.1

if (event.target.value != "") {

    this.getField("JANAVG.1").required = false;

    }

if (event.target.value == "") {

    this.getField("JANAVG.1").required = true;

    }

On the JANAVG.1

if (event.target.value != "") {

    this.getField("AVG.1").required = false;

    }

if (event.target.value == "") {

    this.getField("AVG.1").required = true;

    }

So any help would be great.  I figure the best plan of action is including and either or on the first group of commands but don't know how to do it.

TOPICS
Acrobat SDK and JavaScript
173
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
no replies

Have something to add?

Join the conversation