1
I need to enable/disable a field according to the choice in a radiobutton
Validations
This field should only be active when the "Inactive" radio button is selected Follows code:
Radiobutton:
<asp:Label ID="Label40" runat="server" Width="85px" Style="margin-top: 15px; margin-left: 17.2%;">DADOS</asp:Label>
<div style="border: solid 2px; height: 22px; width: 316px; margin-left: 50.4%; margin-top: -33px;">
<asp:RadioButtonList ID="rdbDados" name="rdbDados" CssClass="radioItens2" runat="server" RepeatDirection="Horizontal" Style="width: 319px;">
<asp:ListItem Text="1º PEDIDO" Value="C" Selected="True"></asp:ListItem>
<asp:ListItem Text="INATIVOS" Value="I"></asp:ListItem>
</asp:RadioButtonList>
</div>
Field that needs to be enabled/disabled
<asp:Label runat="server" Width="90">Nº MESES INATIVIDADE</asp:Label>
<asp:TextBox runat="server" Width="50px" ID="txtInatividade" name="inatividade"></asp:TextBox>
Jquery I tried to develop:
$("#<%=rdbDados.ClientID%>").change(function () {
switch ($("#rdbDados input:radio:checked").val()) {
case "I":
$("#inatividade").prop("disabled", false);
break;
case "C":
$("#inatividade").prop("disabled", true);
break;
}
});