2012-04-04 2 views
0

나는 라디오 버튼 그룹이 있습니다. 그러면 내가 erorr을 던지면 하나가 클릭되었는지 확인해야합니다. 어떻게 Jquery로 아래에서 유효성을 검사 할 수 있습니까? 여기동일한 그룹 이름을 가진 두 개의 라디오 버튼을 확인하는 방법

<legend>Follow Opening Script?</legend> 
<p> 
    <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> 
</p> 
+0

당신은 정말 할 전망을 실제 HTML이 아니라 ASP 태그. – ThiefMaster

+0

http://stackoverflow.com/questions/277589/validation-of-radio-button-group-using-jquery-validation-plugin이 도움이 될까요? – TRR

답변

0

등록 이벤트 문서에 대한 준비 :

$('input[name="OpeningScript"]').click(function() { 
    alert($(this).val()); 
}); 

변경 특정 항목의 상태를 얻을 수있는 인덱스 :

$("input[name*=OpeningScript]")[0].checked 

을 텍스트를 받으려면

$("input[name*=OpeningScript]:checked + label").text(); 
0

Working FIDDLE Demo

당신의 HTML에 button을 추가

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

그리고 그 click 확인 할 수있는 기능을 쓰기 :

$(function() { 
    $('#check').on('click', function() { 
     if (! $('[name="OpeningScript"]:checked').length) { 
      alert('Please choose an option'); 
     } 
    }); 
}); 
관련 문제