Copy link to clipboard
Copied
I am trying to prompt Field B to become required only when Field A contains specific text such as "Apples", "Oranges", and "Bananas".
I have tried this code in the Custom Calculation Script of Field B:
if (this.getField("A").value=="Apples"){event.target.required=true}
else
{event.target.required=false}
Which works, but it won't work when Field A has other words like "Oranges" and "Bananas" with this script:
if (this.getField("Name").value=="Apples", "Oranges", "Bananas"){event.target.required=true}
else
{event.target.required=false}
How can I prompt field B to be required if field A has any of these words in it?
The same as before... This is the whole script:
var v = this.getField("Name").value;
if (v=="Apples" || v=="Oranges" || v=="Bananas")
{event.target.required=true}
else
{event.target.required=false}
Copy link to clipboard
Copied
It will work if you use the correct syntax. One option of doing it is like this:
var v = this.getField("Name").value;
if (v=="Apples" || v=="Oranges" || v=="Bananas") ...
Copy link to clipboard
Copied
What would the rest of the script be? I tried to add the
else
{event.target.required=false}
but got a syntax error.
Copy link to clipboard
Copied
The same as before... This is the whole script:
var v = this.getField("Name").value;
if (v=="Apples" || v=="Oranges" || v=="Bananas")
{event.target.required=true}
else
{event.target.required=false}