title: MVC DropDownListFor and StringLength Attribute Not Playing Well together
body: <p>My stringlength validation always fails on dropdownlists with a string value.</p>
  
  <p>Here is my model:</p>
  
  <pre><code>[Required(ErrorMessage = "Required")]
  [StringLength(2, MinimumLength = 2)]
  [Display(Name = "Home Address State")]
  public string HomeAddressState { get; set; }
  </code></pre>
  
  <p>Here is my view:</p>
  
  <pre><code>@Html.DropDownListFor(model =&gt; model.HomeAddressState, new SelectList(ViewBag.States, "Value", "Text"), string.Empty)
  @Html.ValidationMessageFor(model =&gt; model.HomeAddressState)
  </code></pre>
  
  <p>Here is the html output:</p>
  
  <pre><code>&lt;select data-val="true" data-val-length="The field Home Address State must be a string with a minimum length of 2 and a maximum length of 2." data-val-length-max="2" data-val-length-min="2" data-val-required="Required" id="HomeAddressState" name="HomeAddressState"&gt;&lt;option value=""&gt;&lt;/option&gt;
  &lt;option value="CA"&gt;California&lt;/option&gt;
  &lt;option value="IL"&gt;Illinois&lt;/option&gt;
  &lt;option value="IN"&gt;Indiana&lt;/option&gt;
  &lt;option value="OH"&gt;Ohio&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>No matter what option is selected, the StringLength validation fails client-side. What am I doing incorrectly?</p>