Make Checkboxes act like radio buttons using jQuery

This tutorial shows you how to make Checkboxes act like radio buttons, this really need when the designer designed a quiz page with checkboxes instead of radio buttons and the client wants only in that way. Sad isn’t it?

But don’t worry here is the solution for that, you can see the Demo and Download the script at the bottom of this post if you wish.

jQuery Part:

Here is the demo code to play around with it:

 Check out the demo and download too.

demo download

 

Related Posts

3 thoughts on “Make Checkboxes act like radio buttons using jQuery

    1. Hi, it was not working because the jQuery was not loaded. Please check the demo now it’s working. You could’ve tested it simply by copy-pasting the entire code and save it as an HTML file in your local.

  1. you have to use .prop instead of .attr

    $(function(){
    $(“input:checkbox”).click(function(){
    var checkboxgroup = “input:checkbox[name='”+$(this).attr(“name”)+”‘]”;
    $(checkboxgroup).prop (“checked”,false);
    $(this).prop (“checked”,true);
    });
    });

Leave a Reply