Copy link to clipboard
Copied
I am working on a form that has a required question with multiple choices. If any one of the choices is completed, the question is considered answered. I am attempting to create a hidden field that would work as the check to validate that the question was answered. I would also like if one of the multi-choice fields is cleared out that the hidden test field also clears out. The multiple choices consist of one checkbox and three text fields.
Could someone please assist in correcting ?
var a = this.getField("Checkbox1");
var b = this.getField("TextField1");
var c = this.getField("TextField2");
var d = this.getField("TextField3");
if (a.value=="On"){
event.value = "On";
}
else if (a.value==""){
event.value = "";
}
else if (b.value){
(event.value = b.value);
}
else if (c.value){
event.value = c.value;
}
else if (d.value){
event.value = d.value;
}
else{
event.value = "";
}
Copy link to clipboard
Copied
If I understood you correctly, you can try this:
var a = this.getField("Checkbox1").valueAsString;
var b = this.getField("TextField1").valueAsString;
var c = this.getField("TextField2").valueAsString;
var d = this.getField("TextField3").valueAsString;
if (a=="Off" || b=="" || c=="" || d=="") event.value = "";
else event.value = "OK";
The actual value of the field doesn't matter, as long as it's filled in, since it's hidden.
Copy link to clipboard
Copied
If I understood you correctly, you can try this:
var a = this.getField("Checkbox1").valueAsString;
var b = this.getField("TextField1").valueAsString;
var c = this.getField("TextField2").valueAsString;
var d = this.getField("TextField3").valueAsString;
if (a=="Off" || b=="" || c=="" || d=="") event.value = "";
else event.value = "OK";
The actual value of the field doesn't matter, as long as it's filled in, since it's hidden.
Copy link to clipboard
Copied
So close! But it looks like your script won't populate the target field unless ALL variables are completed. I need it populated with OK if one of the four are completed.
Copy link to clipboard
Copied
Ah, OK. Then change all of the "||" to "&&" (no quotes).
Copy link to clipboard
Copied
THANK YOU! Works perfectly.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more