Copy link to clipboard
Copied
I have a fillable PDF where I'm trying to make required fields if certain actions are made. I can make several fields required if a check box is checked, but I'm struggling to figure out how to make one of two (or more) boxes required, but not all. The user should be able to select more than one so I can't do a radio button. However, if they choose at least one, the remaining options should no longer be required.
Example:
[ ] Check this box if you are having a great day. (If this box is checked, the following two fields become required.)
[ ] Hoke Poke (If this box is checked, the following check box is no longer required)
[ ] Red Light Green Light (If this box is checked, the preceeding check box is no longer required)
I'm using this.getField("chk1").required = event.target.value!="Off"; to make fields required if a checkbox is clicked (if that helps).
I've scoured the web and these forums and maybe I'm not searching the right thing, but I can't find what I'm looking for, thus I seek the communities help in this venture.
Copy link to clipboard
Copied
There is nothing in Acrobat that would give you this behavior with just a couple of mouse clicks. You need to implement this in JavaScript on your own. You very likely not use the required property, but keep track of what is required and what is not in the background, and then when the user tries to submit (or save) the form, you would display a warning or an error.
Copy link to clipboard
Copied
I figured this out!!!!!!!!!!!!!!!!!!!!!!!!
I'm not sure if Adobe recently changed things to allow this, but here's exactly how to do.
I'm working in the webform module.
You create a required radio button. Then, you add a condition to the fields you want to be required if a specific radio button is pressed to say if it's selected "X" then this field shows.
Now, depending on which radio button is pressed, the field shows up and is required. It's so cool! Let me know if you get this!!!
Copy link to clipboard
Copied
This is exactly what I need, however, I cannot fathom out how to achieve? I am not sure whatis meant by webform module and cannot find where conditions are?
Copy link to clipboard
Copied
They are referring to a some kind of web-based form, not a real PDF file. As mentioned, to do this in a PDF you have to use a script. I would use the calculation script of a (hidden) text field to handle all of the scenarios described above, like this:
if (this.getField("chk1").valueAsString=="Off") {
this.getField("chk2").required = false;
this.getField("chk3").required = false;
} else {
this.getField("chk2").required = this.getField("chk3").valueAsString=="Off";
this.getField("chk3").required = this.getField("chk2").valueAsString=="Off";
}
Copy link to clipboard
Copied
Apologies, I have no idea what is meant by script? I simply use Adobe, this seems to be some sort of coding behind Adobe or am I missing the point completely?
Copy link to clipboard
Copied
A script is code that runs within Acrobat, either in the application itself or in a file it opens.
Copy link to clipboard
Copied
Here is an old article i wrote about Acrobat scripting: https://khkonsulting.com/2017/01/learning-to-program-javascript-for-adobe-acrobat/