Expand my Community achievements bar.

SOLVED

Radio button creates mandatory field

Avatar

Level 3

I have a form that has several radio buttons and corresponding Comment boxes.

When the user chooses the No radio button, I want the comments section to become mandatory.

So I wrote

 

if (RadioQ2.rawValue=="2"){

       

Q2.mandatory

 

}

In the binding tab, the No item has a value of 2.

RadioQ2 is the radio buttons and Q2 is the comments for question 2.

This works for No, but also gives the same message for Yes (which = 1).

I am certainly not a programmer by any means, so what I have is probably not correct, but I hope I'm sort of close!

Thanks for your help, Gretchen

1 Accepted Solution

Avatar

Correct answer by
Level 7

try this:

if (RadioQ2.rawValue=="2"){

Q2.validate.nullTest = "error";

}

else {Q2.validate.nullTest = "disabled";

}

View solution in original post

2 Replies

Avatar

Correct answer by
Level 7

try this:

if (RadioQ2.rawValue=="2"){

Q2.validate.nullTest = "error";

}

else {Q2.validate.nullTest = "disabled";

}

Avatar

Level 3

Thank you very much for your help!

Sorry it took me a few days to respnd, I've been out with bronchitis.