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

Required field if conditions only if another box is checked

New Here ,
Jul 24, 2019 Jul 24, 2019

I have two text Fields "Account#" and "Zip" that I have made mandatory when checking one of two boxes (COD Or 3rd Party), Now when checking these boxes the Fields "Account#" and "Zip" outline in red to signify these are now required fields.  What I'm trying to do is then write a script for the "Account#" and "Zip" fields that then removes that outline once the fields have a value, however I also want these fields to go back to being outlined in red if the value in each field has been removed only if the "3rd Party" or "COD" boxes are still checked.

here is the javascript I have written for each checkbox

this.getField("Account#").required = event.target.isBoxChecked(0);

this.getField("Zip").required = event.target.isBoxChecked(0);

Here is the javascript I have written for each "Account#" and "Zip" field to add/remove the red required border

if(event.value != ""){

    event.target.required = false;

}

else {

    event.target.required = true;

}

the problem lies here, I need to modify this to only work if either "3rd Part" or "COD" box is checked.  Right now the box outline will add/remove even if the boxes are not checked.

TOPICS
Acrobat SDK and JavaScript , Windows
361
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