I tried this JavaScript but it doesn’t work – here
I need to change the button’s enabled property to true when the checkbox is checked and to false when it isn’t. This is my code:
<tr>
<td colspan="2" align="center">
<asp:CheckBox ID="cbAcceptAgreement" runat="server" OnClientClick="acceptAgreement(this)" />
<asp:Label ID="lblUserAgreement" runat="server" Text="I accept the " />
<asp:HyperLink ID="hlUserAgreement" runat="server" Text="User Agreement" NavigateUrl="Help/UserAgreement.aspx" />
</td>
</tr>
<tr>
<td colspan="2" align="center">
<asp:Button ID="btnRegister" runat="server" Text="Register" />
</td>
</tr>
<script type="text/javascript">
function acceptAgreement(obj) {
document.getElementById('<%=btnRegister.ClientID%>').disabled = !obj.checked;
}
</script>
Can you help me solve this problem?
Javascript is case sensitive, you have
Objandobjin your function, they must match 🙂To fix, change your function to this: