How to deselect a radio button option?

Certified Lead Developer

Hello,

We have a use case where user needs to select only one option out of multiple options. It is not a mandatory field. Radio button helps in ensuring only one option is selected. However, it doesn't allow user to deselect the option. We tried to set the value of Radio button as null when user is selecting the same option again. But it didn't work.

Hence, we are currently using multiple checkbox fields to handle this use case.

Is there a better approach to handle this scenario?

 

Thanks in advance.

  Discussion posts and replies are publicly visible

  • Hi ,

    According to me whatever approach you have selected is quite possible and applicable.Multi check box with certain validations allow you to solve the issue.As Mike suggested you can also use the creative approach if it suits to your requirement.

    Thanks,
    ravalik
  • 0
    Certified Lead Developer
    in reply to snehab848
    Sorry to hear you don't have 18.1's features available to use yet. I would also like to point out that the only two features I've listed that you can't do in 17.3 (i believe) are the Side-By-Side Layout and Rich Text Icon. So if you wanted to do something similar, you could probably just use an image field right below the radio button field, and the for the image you could use the a!iconIndicator component (with the "REMOVE" icon), and a link configured in the same way. It wouldn't look QUITE as nice as my original version but it might be pretty good.
  • 0
    Certified Lead Developer
    While I applaud the creativity of a lot of the other solutions people have provided, radio buttons aren't meant to be deselected per web standards. Before utilizing a workaround consider how this will impact end users who are use to utilizing radio buttons on many other web interfaces. Additionally, think of the potential burden on future developers that may need to maintain this behavior and figure out what was done.

    I would suggest utilizing a different field type, as you already mentioned.