Copy link to clipboard
Copied
I'm trying to make a form where if any one of 6 checkboxes are not checked, it will make a specified text field required. What I have so far isn't working, and I tried building a provided off of a formula from my previous post. Below is what I've tried using with no success (most likely went way off course here), can someone maybe explain to me why it isn't working, and help me get a script that will work?? Thanks in advance!!
var r1 = this.getField("CB1").valueAsString;
var r2 = this.getField("CB2").valueAsString;
var r3 = this.getField("CB3").valueAsString;
var r4 = this.getField("CB4").valueAsString;
var r5 = this.getField("CB5").valueAsString;
var r6 = this.getField("CB6").valueAsString;
var r7 = this.getField("Text Field");
if (event.r1 != "Off" && event.r2 != "Off" && event.r3 != "Off" && event.r4 != "Off" && event.r5 != "Off" && event.r6 != "Off") {
r7.required = true
} else {
r7.required = false
}
Copy link to clipboard
Copied
The original code with the CORRECTIONS..... jumped the gun and got too excited!
Copy link to clipboard
Copied
Remove the event. before r1, r2, ...
Copy link to clipboard
Copied
Remove all "event." text. != means it's not OFF, in other words it's ON, so
if you want text field to be required while checkboxes are not checked
replace true with false and false with true, you can also add semicolon after false and true.
Put code in text field as "Custom Calculation Script".
Copy link to clipboard
Copied
So I made the changes you both said, and then could only place into custom calculation script for the text field as you said... tested and still nothing came of it. The variables are included in the script, I just left them out to save space in showing you what I have for the "if - else" script now.
if (r1 != "Off" && r2 != "Off" && r3 != "Off" && r4 != "Off" && r5 != "Off" && r6 != "Off") {
r7.required = false
} else {
r7.required = true
}
Copy link to clipboard
Copied
It's actually not even allowing it to stay in the custom calculation script, that's why it's not working. As soon as I click ok to submit it, it immediately changes back to "Value is not calculated."
Copy link to clipboard
Copied
That should work, it must be something else in your file, try share your file with us or
see if this code works for you:
var check = 0;
for (var i=1; i<=6; i++) {
if (this.getField("CB"+i).valueAsString != "Off")check++}
event.target.required = check == 6 ? false : true;
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Hopefully that clarifies a little more as to what I'm trying to do.
I have no issues with getting the respective remarks for Check 'X', and Check 'Y'... it's just the r1...r6 to remarks that's giving me trouble.
Copy link to clipboard
Copied
Soooooo I resolved the problem!!
You were right. what I was doing was correct... I just ended up taking the original code and amending it onto the already existing Mouse Up: Javascript script, separating it with proper {} marks, and verifying all information was accurate. Once I did that and tested it, everything worked!!
In the end it ended up making a 4 long unique scripts (one for r1, r2, r3 and r4, and then r5 and r6), and a 5th short script (base script in original post for "Remarks" as identified in the screenshot provided).
Copy link to clipboard
Copied
The original code with the CORRECTIONS..... jumped the gun and got too excited!
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more