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

Adobe DC - Use checkbox to turn required fields on and off

Community Beginner ,
Mar 11, 2024 Mar 11, 2024

Copy link to clipboard

Copied

Hello:

I am hoping someone can help me with whatever I missing in this if statement.
I would like all the fields on the same page
when the checkbox equals "on"

  • require all the fields

 when the checkbox is "off"

  • clear the fields and remove the required from all the fields


All fields are on the same page, but there a a couple of exceptions, so I cant use the whole page (but I would like to know how to do that for future reference)

Here is what I tried. I have added and removed ' } ; in many combination and cant seem to get this.

Action - Mouse Up > run java

var f1 = this.getField("M M");
var f2 = this.getField("M T");
var f3 = this.getField("TMF");
var f4 = this.getField("TMT");
var f5 = this.getField("WMF");
var f6 = this.getField("WMT");
var f7 = this.getField("THMF");
var f8 = this.getField("THMT");
var f9 = this.getField("FMF");
var f10 = this.getField("FMT");
var f11 = this.getField("BulkAppt");
var f12 = this.getField("TruckType");
var f13 = this.getField("Pump");
var f14 = this.getField("HoseLength");
var f15 = this.getField("ContMate");
var f16 = this.getField("ContSize");
var f17 = this.getField("ContType");
var f18 = this.getField("LoadMeans");
var f19 = this.getField("Grounded");
var f20 = this.getField("Text_AddBulkReq");
var f21 = this.getField("Text_SpecificTankLoc");

if(event.target.value!="On")
{
f1.required=true;
f2.required=true;
f3.required=true;
f4.required=true;
f5.required=true;
f6.required=true;
f7.required=true;
f8.required=true;
f9.required=true;
f10.required=true;
f11.required=true;
f12.required=true;
f13.required=true;
f14.required=true;
f15.required=true;
f16.required=true;
f17.required=true;
f18.required=true;
f19.required=true;
f20.required=true;
f21.required=true;
}

elseif(event.target.value!="Off")
{

f1.required=false;
f2.required=false;
f3.required=false;
f4.required=false;
f5.required=false;
f6.required=false;
f7.required=false;
f8.required=false;
f9.required=false;
f10.required=false;
f11.required=false;
f12.required=false;
f13.required=false;
f14.required=false;
f15.required=false;
f16.required=false;
f17.required=false;
f18.required=false;
f19.required=false;
f20.required=false;
f21.required=false;
}


To anyone who can help - thank you for your valued time in replying to this question

TOPICS
How to , PDF forms

Views

137

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

correct answers 1 Correct answer

Community Expert , Mar 11, 2024 Mar 11, 2024

Try this:

var fields = ["M M","M T","TMF","TMT","WMF","WMT","THMF","THMT","FMF","FMT","BulkAppt","TruckType","Pump","HoseLength","ContMate","ContSize","ContType","LoadMeans","Grounded","Text_AddBulkReq","Text_SpecificTankLoc"];

for( var i in fields){
 if(event.target.value != "Off")
  this.getField(fields[i]).required = true;
 else{
  this.getField(fields[i]).required = false;
  this.getField(fields[i]).value = "";}}

Votes

Translate

Translate
Community Expert ,
Mar 11, 2024 Mar 11, 2024

Copy link to clipboard

Copied

Try this:

var fields = ["M M","M T","TMF","TMT","WMF","WMT","THMF","THMT","FMF","FMT","BulkAppt","TruckType","Pump","HoseLength","ContMate","ContSize","ContType","LoadMeans","Grounded","Text_AddBulkReq","Text_SpecificTankLoc"];

for( var i in fields){
 if(event.target.value != "Off")
  this.getField(fields[i]).required = true;
 else{
  this.getField(fields[i]).required = false;
  this.getField(fields[i]).value = "";}}

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
Community Beginner ,
Mar 11, 2024 Mar 11, 2024

Copy link to clipboard

Copied

LATEST

Thank you so very, very much!!   I have added to my OneNote of solutions for Adobe.  

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