title: Manually wiring up unobtrusive jquery validation client-side without Model/Data Annotations, MVC3
body: <p>After searching and experimenting for 2 days I relent.  What I'd like to do is manually wire up injected html with jquery validation.  I'm getting a simple string array back from the server and creating a select with the strings as options.  The static fields on the form are validating fine.  I've been trying the following:</p>
  
  <pre><code>var dates = $("&lt;select id='ShiftDate' data-val='true' data-val-required='Please select a date'&gt;");
  dates.append("&lt;option value=''&gt;-Select a Date-&lt;/option&gt;");
  for (var i = 0; i &lt; data.length; i++) {
      dates.append("&lt;option value='" + data[i] + "'&gt;" + data[i] + "&lt;/option&gt;");
  }
  $("fieldset", addShift).append($("&lt;p&gt;").append("&lt;label for='ShiftDate'&gt;Shift Date&lt;/label&gt;\r").append(dates).append("&lt;span class='field-validation-valid' data-valmsg-for='ShiftDate' data-valmsg-replace='true'&gt;&lt;/span&gt;"));
  
  // I tried the code below as well instead of adding the data-val attributes and span manually with no luck
  dates.rules("add", {
      required: true,
      messages: {
          required: "Please select a date"
      }
  });
  
  // Thought this would do it when I came across several posts but it didn't
  $.validator.unobtrusive.parse(dates.closest("form"));
  </code></pre>
  
  <p>I know I could create a view model ,decorate it with a required attribute, create a SelectList server-side and send that, but it's more of a "how would I do this" situation now.  Can anyone shed light on why the above code wouldn't work as I expect?</p>
  
  <p>-chad</p>