Since asp/asp.net doesn’t have a form validator to check checkboxes we need to use a custom validator.
So here’s a very simple and crude way to achieve this

The 4 Guys From Rolla have an article on a more comprehensive way to do this, but if you don’t mind quick and dirty continue reading.
Their article can be found here : http://aspnet.4guysfromrolla.com/articles/092006-1.aspx

// So you have something like this in the view to represent the checkbox to be validated and the CustomValidator
Confirm action

// then you place the Validation Method into the code-behind or a code block on the page.
protected void CustomConfirmationValidate(object source, ServerValidateEventArgs args)
{
  args.IsValid = ConfirmationCheckbox.Checked;
}

// and to control the actions you check for Page.IsValid before you do what you want to do.. i.e.
if (!Page.IsValid)
{
  // Page is invalid so we don't do anything.
  return;
}

One Response to A (very) simple way to validate a checkbox in asp.net

  1. Andrew Deniel says:

    Hi,

    This is very informative article. Thanks for sharing your knowledge. There are few links that also helpful for developers. This article have described to validate CheckBox, CheckBoxList, DropDownList, FileUpload, RadioButton, RadioButtonList, TextBox using jquery.

    http://mindstick.com/Articles/c3825daa-a449-467d-9513-34a8232d498a/?Validations%20on%20Asp%20Net%20Control

    http://www.aspdotnet-suresh.com/2012/09/jquery-validate-checkboxlist-in-aspnet.html