Copy link to clipboard
Copied
Hi, I have the JS on a mouse up:
this.getField("Text Box 1").required = event.target.value!="Off";
to get a field (Text Box 1) to be required to be filled in if the check box is ticked, when preparing forms in Acrobat.
But I'm trying to find a way that it's one of (or up to) four boxes that needs to be filled in if the check box is ticked, not just one.
Can anyone help me with what the script would be to have a list of "text Box 1" AND/OR "text box 2" AND/OR "Text Box 3" please?
Having a "," between the values doesn't seem to work and I'm still learning JS - so help is much apprecaited, thank you 🙂
Copy link to clipboard
Copied
First, you need to clearly state the desired behavior. "And/Or" is ambiguous because "AND" and "OR" are different things. So your description needs to cover all cases, for example: when the checkbox A is checked fields x,y and z become required, when the checkbox A is unchecked fields x,y and z become not-required. You say "up to". What does this mean? are there 4 text boxes and in different situations different ones need to be required? Be exact.
Copy link to clipboard
Copied
Thanks Thom.
Yes sure. To clarify. I have a 'Yes' and 'No' check box. If they check 'Yes', then it needs them to fill in at least one of the 6 text boxes below, hence the and/or (but understand that that could be ambiguous). They can fill in 1, 2, 3, 4, 5 or 6 or more than one in any combination, but at least one. If "no' then, ideally, they should not be able to fill in any of the 6 boxes.
So I was thinking it was a case of adding in the other values 'Text box 1", "text box 2" etc but this didn't work as I don't yet know enough about JS.
Hopefully that helps explain it. Thanks for your help.
Copy link to clipboard
Copied
You have a complex/dynamic requirement that goes beyond the standard "required" behavior, so as Try says, a custom validation script is the way to go. How is this form being submitted? For the regular "required" property, the submit triggers the validation. If the validation fails, then the form doesn't submit and the user gets a message to fill all required fields. But there are other ways to do this. For example, the validation script could be used to change the backgroud of the 6 fields to red until at least one is filled out. Or something along these lines. The methodology depends on how the form is expected to be used.
Copy link to clipboard
Copied
The required property doesn't work that way. If you define multiple fields to be required (that's not part of a group) then they all need to be selected. For what you're describing you would need to use a custom validation script to check that at least one of the fields is filled in before submitting the form.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now