How to check two radio buttons with the same groupname

Go To


i have a group of Radio buttons and i need to check if one has been clicked if not then throw an erorr how can i validate the below with Jquery?

<legend>Follow Opening Script?</legend>
    <strong><asp:RadioButton GroupName="OpeningScript" CssClass="inline-radio" ID="rdoOpeningScriptYes" runat="server" Text="Yes" TextAlign="Right" /></strong>&nbsp;&nbsp;
    <strong><asp:RadioButton GroupName="OpeningScript" CssClass="inline-radio" ID="rdoOpeningScriptNo" runat="server" Text="No" TextAlign="Right" /></strong>
2012-04-04 07:27
by Code Ratchet
You should really post the actual HTML, not the asp tags - ThiefMaster 2012-04-04 07:29 will this help - TRR 2012-04-04 07:30


Here a jsfiddle example for you:

2012-04-04 07:39
by Michal B.


Register event on document ready:

$('input[name="OpeningScript"]').click(function () {

Change the index to get the status of particular item:


To get the text try:

$("input[name*=OpeningScript]:checked + label").text();
2013-05-20 09:20
by Nag


Working FIDDLE Demo

Add a button to your HTML:

<input type="button" id="check" value="check" />

And write a function for its click to check:

$(function () {
    $('#check').on('click', function () {
        if (! $('[name="OpeningScript"]:checked').length) {
            alert('Please choose an option');
2013-05-20 09:26
by NoName