Copy link to clipboard
Copied
Hello everyone,
im new to using JavaScript and could really need some help. I´ve created a form in Adobe pro and what i want is the following:
If field "Comment1" contains any text user is enforced to pick a choice from drop down menu "R1" and "L1". Is it best to use validation script for this? Or calculation script?
I got over 100 rows that i want the same function in, they are named: Comment1, R1, L1; Comment2, R2, L2; Comment3, R3, L3; And so on..
I hope this post makes some sense,
Thanks in advance, Adrian
OK, then I misunderstood before. Enter this code as a doc-level script:
function setDropdownsAsRequired() {
var fieldNumber = event.target.name.replace("Comment", "");
this.getField("R"+fieldNumber).required = (event.value!="");
this.getField("L"+fieldNumber).required = (event.value!="");
}
Then you just need to call it from the custom validation script of your Comment fields, like this:
setDropdownsAsRequired();
Copy link to clipboard
Copied
"Enforce" how, exactly? You can set them as required, but only gets validated when the form is submitted (unless a script is used to validate it during other events). Is that what you mean?
Also, what are the actual field names of the drop-downs? Not just their options...
Copy link to clipboard
Copied
Thanks for your reply!
Yes, setting them as required is exactly what i mean. The field names of the dropdowns are as i wrote: R1, L1 for the first row and then R2, L2 for second row and so on.
Thanks in advance, Adrian
Copy link to clipboard
Copied
So there are two drop-downs for each comment field?
Copy link to clipboard
Copied
Yes, that is correct
Copy link to clipboard
Copied
OK, then I misunderstood before. Enter this code as a doc-level script:
function setDropdownsAsRequired() {
var fieldNumber = event.target.name.replace("Comment", "");
this.getField("R"+fieldNumber).required = (event.value!="");
this.getField("L"+fieldNumber).required = (event.value!="");
}
Then you just need to call it from the custom validation script of your Comment fields, like this:
setDropdownsAsRequired();
Copy link to clipboard
Copied
It worked and was exactly what i was after!
Thanks alot, you saved my day!
Regards, Adrian