Copy link to clipboard
Copied
I have a group (Group2) of radiobuttons with 3 options.
Option1
Option2
Option3
When Option1 is selected I want field Text14 to be mandatory. When option 2 or 3 are selected it should not be mandatory.
I have tried putting code in mouse Up/Javascript
if (event.target.value == "Yes")
{this.getField("Text14").required = true;}
But it's not working.
What am I doing wrong here?
Copy link to clipboard
Copied
Your choice is 'Option1' not "Yes".
Use this as custom calculation script of the field you wish to make required;
event.target.required = this.getField("Group2").valueAsString === "Option1" ? true : false;
Copy link to clipboard
Copied
Use this as custom calculation script of that text field:
var rb = this.getField("Group2").valueAsString;
event.target.required = (rb === "Option1" || rb === "Option4") ? true : false;
Copy link to clipboard
Copied
If you need a custom calculation script, you can place it in any text field, you can even make a text field and hide it and place script in it. Let's say you want to make Group5 required, depending on selections from Group2 and Group4, a custom calculation script:
var g2 = this.getField("Group2").valueAsString;
var g4 = this.getField("Group4").valueAsString;
var g5 = this.getField("Group5");
g5.required = (g2 === "Option1" && g4 === "Option2") ? true : false;
Copy link to clipboard
Copied
Use also a else
Copy link to clipboard
Copied
I tried this
if (event.target.value == "Yes")
{this.getField("Text14").required = true;}
else
{this.getField("Text14").required = false;}
but still not working
Copy link to clipboard
Copied
Your choice is 'Option1' not "Yes".
Use this as custom calculation script of the field you wish to make required;
event.target.required = this.getField("Group2").valueAsString === "Option1" ? true : false;
Copy link to clipboard
Copied
Thank you this worked perfectly
Copy link to clipboard
Copied
Thank you for your previous help. I'm still working on the same form, but needed to add an option.
I have a group (Group2) of radiobuttons with 4 options.
Option1
Option2
Option3
Option4
When Option1 or Option4 are selected I want field Text14 to be mandatory. When option 2 or 3 are selected it should not be mandatory.
I've been working with if, or, else. but I can't seem to find the right code
Copy link to clipboard
Copied
Use this as custom calculation script of that text field:
var rb = this.getField("Group2").valueAsString;
event.target.required = (rb === "Option1" || rb === "Option4") ? true : false;
Copy link to clipboard
Copied
Thank you for your help. The form works so much better already.
What if I want to make a field mandatory based on 2 groups?
So if Group 2 option 1 is true and Group 4 option 2 is true
Copy link to clipboard
Copied
and is it at all possible to make a group mandatory bases on an option chosen in another group.
I noticed the groups don't have the custom calculation field
Copy link to clipboard
Copied
If you need a custom calculation script, you can place it in any text field, you can even make a text field and hide it and place script in it. Let's say you want to make Group5 required, depending on selections from Group2 and Group4, a custom calculation script:
var g2 = this.getField("Group2").valueAsString;
var g4 = this.getField("Group4").valueAsString;
var g5 = this.getField("Group5");
g5.required = (g2 === "Option1" && g4 === "Option2") ? true : false;
Copy link to clipboard
Copied
thank you so much. I'm trying this on Monday
Copy link to clipboard
Copied
It works perfectly. thank you so much