I have a group of RadioButton
which will set off an onclick
event. The pageLoad
and onclick
event (SecurityCheckedChanged
) work because the other show
/hide
JavaScript code works. I've commented it out to give a minimal example. However, setting disable true
/false
in SecurityCheckedChanged
doesn't seem to work (it does work in pageLoad
though). Is what I'm doing correct or is there another way to enable/disable a TextBox
?
JavaScript:
function pageLoad(sender, args) {
$("#<%= textBoxPassword.ClientID %>").attr("disabled", true);
//more show/hide code
}
function SecurityCheckedChanged() {
if ($("#<%= radWEP.ClientID %>").is(':checked')) {
$("#<%= textBoxPassword.ClientID %>").attr("disabled", false);
//more show/hide code
}
else if ($("#<%= radWPA.ClientID %>").is(':checked') || $("#<%= radWPA2.ClientID %>").is(':checked')) {
$("#<%= textBoxPassword.ClientID %>").attr("disabled", false);
//more show/hide code
}
else {
$("#<%= textBoxPassword.ClientID %>").attr("disabled", true);
//more show/hide code
}
}
HTML:
<div style="text-align: left;">
<asp:Localize ID="locPassword" runat="server" Text="Password:" meta:resourcekey="locPasswordRc1" />
<asp:TextBox ID="textBoxPassword" TextMode="Password" runat="server"></asp:TextBox>
</div>
<div style="text-align: left;">
<asp:RadioButton id="radNone" Text="None" Checked="True" meta:resourcekey="radNoneRc1"
GroupName="RadioGroupSecurity" runat="server" onclick="SecurityCheckedChanged()"/>
<asp:RadioButton id="radWEP" Text="WEP" Checked="False" meta:resourcekey="radWepRc1"
GroupName="RadioGroupSecurity" runat="server" onclick="SecurityCheckedChanged()"/>
<asp:RadioButton id="radWPA" Text="WPA" Checked="False" meta:resourcekey="radWpaRc1"
GroupName="RadioGroupSecurity" runat="server" onclick="SecurityCheckedChanged()"/>
<asp:RadioButton id="radWPA2" Text="WPA2" Checked="False" meta:resourcekey="radWpa2Rc1"
GroupName="RadioGroupSecurity" runat="server" onclick="SecurityCheckedChanged()"/>
</div>
NOTE: Also, I understand I shouldn't intermix C# code here. I'll get to cleaning that up a bit later.