<script type="text/javascript">
function che() {
var ch = document.getElementById('<%=CheckBox1.ClientID %>');
if (Page_ClientValidate()) {
if (!ch.checked) {
alert("Please select checkbox first.");
return false;
}
}
}
</script>
HTML-------------------------------------
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator id="rq1" ControlToValidate="TextBox1" ErrorMessage="Name cannot be blank" Display="Dynamic" runat="server"/>
<asp:CheckBox ID="CheckBox1" runat="server" />
<asp:Button ID="Button1" runat="server" Text="Button"
OnClientClick="return che();" onclick="Button1_Click" ValidationGroup="2" />
function che() {
var ch = document.getElementById('<%=CheckBox1.ClientID %>');
if (Page_ClientValidate()) {
if (!ch.checked) {
alert("Please select checkbox first.");
return false;
}
}
}
</script>
HTML-------------------------------------
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator id="rq1" ControlToValidate="TextBox1" ErrorMessage="Name cannot be blank" Display="Dynamic" runat="server"/>
<asp:CheckBox ID="CheckBox1" runat="server" />
<asp:Button ID="Button1" runat="server" Text="Button"
OnClientClick="return che();" onclick="Button1_Click" ValidationGroup="2" />