Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Java Scripting radio buttons to make other fields mandatory

Avatar

Former Community Member

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{

}

2 Replies

Avatar

Level 7

you need to put an else result in:

else {

comappFC1.manadatory = "disabled";

comappNUM1.mandatory = "disabled";

}

Avatar

Former Community Member

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";

}