Expand my Community achievements bar.

Radio Button Mandatory Based on Previous Radion Button

Avatar

Former Community Member

Hi I'm having trouble, and I'm very new at Livecycle.

I'm trying to make a radio group mandatory if another radio button is selected. What am I doing wrong??
The form won't print even WoundRadio1 is selected (it should).

Here's the logic I need. If woundRadio2 is selected then CleanseRadio radio group is manadatory. The code is below. CleanseRadio is set as Required. What am I missing here???

----- form1.#subform[0].Table7.Row1.#subform[0].WoundRadio.WoundRadio1::cli ck: - (JavaScript, client)

if (this.rawValue==1)

{
CleanseRadio.mandatory='disabled';
}

----- form1.#subform[0].Table7.Row1.#subform[0].WoundRadio.WoundRadio2::cli ck: - (JavaScript, client)

if (this.rawValue==1)
{
CleanseRadio.mandatory='error';
}
else {


CleanseRadio.mandatory='disabled';
}

7 Replies

Avatar

Former Community Member

Try it with out the "If "statement since radio buttons are either one or the other.

form1.#subform[0].Table7.Row1.#subform[0].WoundRadio.WoundRadio1::click: - (JavaScript, client)

CleanseRadio.mandatory="disabled";


form1.#subform[0].Table7.Row1.#subform[0].WoundRadio.WoundRadio2::click: - (JavaScript, client)

CleanseRadio.mandatory="error";

Also, make sure you reference CleanseRadio if it's not in the same place as WoundRadio. (ex: Table6.Row1.#subform[0].CleanseRadio)

Avatar

Former Community Member

Hi, made the changes you suggested. Still get the mandatory field error firing when printing. Anything else I should look for?

Avatar

Level 2

If you look at the binding tab of the woundradio group it will show what the value is for each specific radio button in the group, they will have different values.  In your code you have this.rawValue == 1 for both I'm assuming it should be different, similar to mine below. 

Below is my sample script

form1.p1.WoundRadio.WoundRadio1::click - (JavaScript, client)

if (this.rawValue == 1){

  CleanseRadio.validate.nullTest = "error";

}

  

 

if (this.rawValue == 2){

   CleanseRadio.validate.nullTest = "disabled";

}

form1.p1.WoundRadio.WoundRadio2:click - (JavaScript, client)

Avatar

Level 10

It looks like you are putting the code on the individual radio buttons instead of on the radio button group (the exclusion group):

Other than that the code looks ok except that you are using single quotes instead of double quotes around the values:

= 'disabled'; should be = "disabled";

Avatar

Former Community Member

I've made a simple form with 2 radio button groups with the same names and the JS suggested.Still can't get it to work.I've attched a screenshot of the form and the code. Any suggesstions??Livecycle Screenshot.jpg

Avatar

Level 10

From another recent message on here it looks like nulltest doesn't work on radio buttons so try using mandatory again instead. I always use the mandatory setting.

Also make sure the values you are testing match the values of the exclusion group.

Avatar

Level 2

The reason for the issue was the context of the script and the scope of the objects being referred to was incorrect.

You can use either

Textfield.validate.nullTest =  "error"

or Textfield.mandatory = "error"

Both will work