title: Validate a Checkbox
body: <p>I've looked at a dozen previous answers on here nothing has worked for me. I need a form where a checkbox must be checked in order to submit. I am using C# and am pretty new to it, I just found out the RequiredFieldValidator that works with text box's won't work with checkboxes so I need another way to do this.</p>
  
  <p>On submit the data in the fields gets sent to a MS SQL database. I have more fields then the one's shown below but I thought I would condense it for this post and removed everything but one text box and the checkbox I need validated upon submit.</p>
  
  <p>I'd like it to do this on submit:</p>
  
  <p><img src="https://i.stack.imgur.com/XvtW3.jpg" alt="enter image description here"></p>
  
  <pre><code>&lt;form id="form1" runat="server"&gt;
      &lt;asp:Label ID="NameLbl" runat="server" Text="Label"&gt;&lt;/asp:Label&gt;&lt;asp:RequiredFieldValidator
          ID="NameRFV" runat="server" ErrorMessage="NameTxtBox"&gt;&lt;/asp:RequiredFieldValidator&gt;
      &lt;asp:TextBox ID="NameTxtBox" runat="server"&gt;&lt;/asp:TextBox&gt;
      &lt;br /&gt;
      &lt;asp:Label ID="AliveLbl" runat="server" Text="Are you alive?"&gt;&lt;/asp:Label&gt;
      &lt;asp:CheckBox ID="AliveChkBox" runat="server" /&gt;
      &lt;asp:Button ID="Submit" class="btn btn-primary" runat="server" Text="Submit"  OnClick="Submit_Click" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I've read about using CustomValidator but I can't get anything to function properly with it. People keep saying you need to compile/build your code for it to work and I simply don't no how to do that. </p>
  
  <p>Will consider javascript options as well. I can also use a CheckboxList instead if you know of a better way to validate those. </p>