Show hide TextBox on RadioButtonList selection using jQuery in ASP.Net

Last Reply 9 months ago By pandeyism

Posted 9 months ago



i have asp dot net radio button list which has 2 options Yes and No.

i want javascript that if user select Yes so textbox visible and its set the value of textbox to "I am selected" and if user select No textbox hide


please advice

You are viewing reply posted by: pandeyism 9 months ago.
Posted 9 months ago

Hi nauna,

Please refer below sample.


<asp:RadioButtonList ID="rblYesNo" runat="server">
    <asp:ListItem Text="Yes" Value="Yes"></asp:ListItem>
    <asp:ListItem Text="No" Value="No"></asp:ListItem>
<asp:TextBox ID="txtData" runat="server" />
<script type="text/javascript" src=""></script>
<script type="text/javascript" language="javascript">
$("document").ready(function () {
    $("#<%= rblYesNo.ClientID%> input").change(function () {
        if ($(this).val() == 'No') {
            $('#<%= txtData.ClientID%>').hide();
        else {
            $('#<%= txtData.ClientID%>').show();
            document.getElementById('<%=txtData.ClientID%>').value = "I am selected";
        return false;