Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Java Scripting radio buttons to make other fields mandatory

Avatar

Level 2

I am trying to java script a yes/no set of radio buttons so that if someone marks the yes button a nearby numeric field becomes mandatory.  The script I'm using seemed to work but once the person marks the yes button one time, even if they go back and change their answer to no it keeps giving them the mandatory field error message.  Does anyone know what my script is missing?  Here it is

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

comappFC1.mandatory = "error";
}
else{

}

0 Replies

Avatar

Level 7

you need to put an else result in:

else {

comappFC1.manadatory = "disabled";

comappNUM1.mandatory = "disabled";

}

Avatar

Level 2

That didn't seem to work.  It is still giving me the error message if I click the "yes" button one time, even if I go back and change my answer to "no".  If I originally click the "no" button, it will let me proceed.  But if I click "yes" it gives me an error (which I want), but the problem is that it wont let you change your anawer back to "No".  It is as if once the command is activated it doesnt recognize if you unclick the "yes" button.  Does that make sense?  Here is the new script I entered with your recommended changes..

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

comappFC1.mandatory = "error";
}
else{
comappFC1.manadatory = "disabled";

comappNUM1.mandatory = "disabled";

}