title: Trouble with checkbox validation in Razor form
body: <p>I am currently at an internship and am completely new to Razor and C# MVC. I am currently building a simple Razor form, but my validation is giving me grief for a check box.</p>
  
  <p>Here is my model code:</p>
  
  <pre><code>[DisplayName("Sign me up for spam* ")]
  [Range(typeof(bool), "true", "true", ErrorMessage = "You must sign up for spam.")]
  public bool Check { get; set; }
  </code></pre>
  
  <p>Here is my Razor markup:</p>
  
  <pre><code>@Html.LabelFor(model =&gt; model.Check, new { @class = "" })
  @Html.CheckBoxFor(model =&gt; model.Check, new { @class = "example1"})
  </code></pre>
  
  <p>Here is the generated HTML:</p>
  
  <pre><code>&lt;input class="example1" data-val="true" data-val-range="You must sign up for spam." data-val-range-max="True" data-val-range-min="True" data-val-required="The Sign me up for spam*  field is required." id="Check" name="Check" type="checkbox" value="true"&gt;
  &lt;input name="Check" type="hidden" value="false"&gt;
  </code></pre>
  
  <p>I know that Razor will generate both inputs automatically. My problem is that the validation is simply not working on the check box. The model state is always invalid because of it, and on the client side the error message appears when the box is checked and disappears when the box is unchecked. I have been googling for answers, but have come up short and my mentor doesn't know what is going screwy either.</p>