Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session
SOLVED

Java Scripting Conditional fields

Avatar

Former Community Member

I am trying to enter a Java Script for a set of yes/no radio buttons, where if you enter yes it will require you to enter text in a nearby numeric field.  The script i'm using seems to work, but once the user enters yes just one time, it will not let them change their answer back to no without getting the error message saying that they need to enter text in the other field.  Can anyone help me with what I'm doign wrong?  Here is the script I'm using.

'2' is the value for yes and comappNUM1 and commappFC1 are the field names I want to be required if yes is chosen.  I'm guessing something needs to tell it to disable if no is selected.

if(this.rawValue =='2')
{
comappNUM1.mandatory = "error";

comappFC1.mandatory = "error";
}
else{

}

1 Accepted Solution

Avatar

Correct answer by
Level 5

You have to use the script in the Change-Event from the RadioButtonList!

The ' ' is wrong.

//if (this.rawValue == "2") you can also use "2"

if (this.rawValue == 2)

{

comappNUM1.mandatory = "error";

comappFC1.mandatory = "error";

}else

{

comappNUM1.mandatory = "disabled";

comappFC1.mandatory = "disabled";

}

I hope this is helpfull,

Mandy

View solution in original post

3 Replies

Avatar

Correct answer by
Level 5

You have to use the script in the Change-Event from the RadioButtonList!

The ' ' is wrong.

//if (this.rawValue == "2") you can also use "2"

if (this.rawValue == 2)

{

comappNUM1.mandatory = "error";

comappFC1.mandatory = "error";

}else

{

comappNUM1.mandatory = "disabled";

comappFC1.mandatory = "disabled";

}

I hope this is helpfull,

Mandy