Copy link to clipboard
Copied
Hi, I know almost nothing about writing scripts for forms, so please be tolerant if I'm asking a really simple question.
I've created a form where the user needs to indicate whether an ordinance is new, amended, or expiring. I want the user to be able to select only one of the above otpions. If new, I want the Effective date to be required; if amended (major or minor), I want the Amendment date to be required; if expiring, I want the Expiration date to be required.
I have four options, but I only want to use three text boxes. If I use checkboxes set to act like radio buttons (same name but different Export Values set in Options), I can force the user to select only one option (I've done this with the Updated (major) and Updated (minor); however, I don't know how to make Amendment date required when two check boxes are in play (Amendment date is required if either Updated (major) or Updated (minor) is checked.)
My other option is to use radio buttons and make the applicable text boxes required. This works, but, as you can see, the text box linked to the last selected radio button doesn't clear when I reset the form.
This is the code I'm using in the Action field of the radio button:
if (event.target.value = "Choice3") {
this.getField("EffectiveDate1").required = false;
this.getField("AmendmentDate1").required= true;
this.getField("ExpirationDate1").required= false;
}
This is the code I'm using in the Calculate function of the text box (I use this for the forms with radio buttons and check boxes): event.target.required=(this.getField("CheckBox2").value!="Off");
So my questions are: (1) if I use check boxes, how do I make my required text box dependent on multiple check boxes (Updated major and minor)? and/or (2) if I use radio buttons, how do I get the required field indicator to go away when I reset the form?
I'm using Acrobat Pro Continuous Release | Verson 2022.003.2058m, and I'm working on a Mac. I really don't know anything about writing the required script (you can tell this isn't my "real" job), so any advice you can provide in really simple terms would be greatly appreciated.
TIA
Copy link to clipboard
Copied
When comparing use double == like this:
if (event.target.value == "Choice3")
Copy link to clipboard
Copied
Ah, thank you!