Copy link to clipboard
Copied
I have a signature field, named "CredSig1", that I would like to make required based on dropdown selections at "cred" in which has a list of credentialing roles (i.e. Audiologist, Registered Nurse, Medical Assistant, etc.).
I have set a validation script below that works for "Audiologist", however, I cannot get others to work simultaneously:
var target = this.getField("CredSig1");
target.required = event.value == "Audiologist" ? true : false;
How can i script it to identify multiple values if one is selected to make a field required?
FYI, there is only one selection in this field. I would like Audiologist, Registered Nurse, Physicians, or Nurse Practitioner, if selected to make "CredSig1" required.
Thank you in advance.
Copy link to clipboard
Copied
Handling multiple values requires a "if" statement:
Read this:
https://www.pdfscripting.com/public/How-to-write-an-If-statement.cfm
Copy link to clipboard
Copied
where do I start the if statement for this particular set?
Copy link to clipboard
Copied
You haven't outlined the specific required conditions, but here's a script that makes the target required if any of several values are selected. If the requirements are different, then the logic in the "if" will need to be modified.
if((event.value == "Audiologist") || (event.value == "Registered Nurse") || etc.)
target.required = true;
else
target.required = false;
Copy link to clipboard
Copied
Thank you I finally got it using your script. I added the var target = ("CredSig1") to make it align.
Copy link to clipboard
Copied
Correct, I only included the "if" part of the code since that's the piece that was missing.
There's actually several ways this could be done, including a modification to your original code.
And Nesa provided a novel and clever method.
Copy link to clipboard
Copied
You can do it like this:
var target = this.getField("CredSig1");
var requiredRoles = ["Audiologist", "Registered Nurse", "Physician", "Nurse Practitioner"];
target.required = requiredRoles.indexOf(event.value) !== -1;
Find more inspiration, events, and resources on the new Adobe Community
Explore Now