我有一个复选框、标签和按钮控件。如果未选中复选框并单击按钮,我需要在标签中显示一条消息,说明首先选中复选框。如果选中复选框然后单击按钮,它应该允许我继续。
这与条款和条件屏幕非常相似,如果您不选中复选框 - 您将无法继续。
我正在使用下面的 javascript。请让我知道如何完成此功能?
<script type="text/javascript">
function testCheckbox() {
var obj = document.getElementById('<%= chkTerms.ClientID %>');
if (obj.checked == false) {
document.getElementById("lblCheck").style.visibility = "visible";
return false;
}
}
</script>
<asp:Label ID="lblTerms" runat="server" Text="I agree to the Terms and Conditions"> </asp:Label>
<asp:Label ID="lblCheck" runat="server" Text="Please agree to the terms and conditions to proceed"></asp:Label>
<asp:Button ID="btnProceed" runat="server" OnClientClick ="return testCheckbox()" OnClick="btnProceed_Click" Text="Submit" />