In my application, I need radiobutton, but if the user clicks a radio button they can't unclick them (so it becomes mandatory once they've chosen one). I can not use radiobutton list. can some one give the idea?
You can provide them a "clear selection" button maybe and then you can use some javascript to clear the selection. Let me know if this is what you're looking for, I can provide some sample code.
you are going to have to disable the radio button once it has been clicked. You can do this with JavaScript and I am sorry I just cant think of how to write the code off the top of my head. :<
You cannot uncheck a radiobutton unless you have multiple radiobuttons of the same group
<asp:RadioButton
ID="RadioButton1"
runat="server"
GroupName
=
"radio"
/>
<asp:RadioButton
ID="RadioButton2"
runat="server"
GroupName
=
"radio"
/>
<asp:RadioButton
ID="RadioButton3"
runat="server"
GroupName
=
"radio"
/>
Else if you have only one radiobutton use a checkbox instead
bjcanada
Member
8 Points
108 Posts
how to uncheck the radio button
Jun 22, 2009 03:59 PM|LINK
Hi all,
In my application, I need radiobutton, but if the user clicks a radio button they can't unclick them (so it becomes mandatory once they've chosen one). I can not use radiobutton list. can some one give the idea?
Thanks in advance!
DarrellNorto...
All-Star
86555 Points
9624 Posts
Moderator
MVP
Re: how to uncheck the radio button
Jun 22, 2009 05:07 PM|LINK
Darrell Norton's Blog
Please click "Mark as Answer" if this helped you.
tamilcodes
Contributor
3140 Points
690 Posts
Re: how to uncheck the radio button
Jun 22, 2009 05:29 PM|LINK
you cannot uncheck the radio button once selected.
TUTORIAL RIVER - HTML, ASP.NET, PHOTOSHOP, WEB DESIGN TUTORIALS
MetalAsp.Net
All-Star
112032 Points
18231 Posts
Moderator
Re: how to uncheck the radio button
Jun 22, 2009 05:31 PM|LINK
You can provide them a "clear selection" button maybe and then you can use some javascript to clear the selection. Let me know if this is what you're looking for, I can provide some sample code.
docluv
Star
12685 Points
2005 Posts
ASPInsiders
MVP
Re: how to uncheck the radio button
Jun 22, 2009 05:36 PM|LINK
you are going to have to disable the radio button once it has been clicked. You can do this with JavaScript and I am sorry I just cant think of how to write the code off the top of my head. :<
mudassarkhan
All-Star
78956 Points
13402 Posts
MVP
Re: how to uncheck the radio button
Jun 22, 2009 05:40 PM|LINK
Else if you have only one radiobutton use a checkbox instead
Contact me
bjcanada
Member
8 Points
108 Posts
Re: how to uncheck the radio button
Jun 22, 2009 06:54 PM|LINK
Thanks a lot for your guys reply. I got the solution
zameb
Member
14 Points
12 Posts
Re: how to uncheck the radio button
Jun 17, 2010 09:43 AM|LINK
There are scenarios where Checkbox is not a solution:
What if you have to select JUST ONE of N options? What if at same time, you should provide a user a way to unselect or clear the selection?
By using checkboxes, you prefer to uncheck every single option by code? Not hard, but kinda sucks
By using radiobuttons, you can just set the Checked property to false in the code behind:
radioCard.Checked = false;
maxelmo
Member
2 Points
1 Post
Re: how to uncheck the radio button
Oct 01, 2010 11:11 AM|LINK
The follwing code works like a charm
$(document).ready(function() {
$("input[type='radio']").mousedown(function(e) {
if ($(this).attr("checked") == true) {
setTimeout("$('input[id=" + $(this).attr('id') + "]').removeAttr('checked');", 200);}
else {
return true
}
});
});