title: Validate a Hidden Field
body: <p>I'm using MVC3 with unobtrusive validation. I have a field that the user is expected to fill with some data and then press a "search" button. If search has never been pressed or the user has changed the input field after pressing search, the form should not be possible to submit.</p>
  
  <p>I've added a hidden field that is set to <code>true</code> by the <code>click()</code> event of the button and emptied by the <code>keyup()</code> event of the input box. Now I would like to add a validation rule that requires the hidden field to be <code>true</code> to allow submit.</p>
  
  <p>Preferably I would like to use unobtrusive validation, but if that doesn't work it is ok with something that requires some javascript, as long as it doesn't spoil the unobtrusive validation for the rest of the form.</p>
  
  <p>The following code snippet does exactly what I want, until I add <code>type="hidden"</code>.</p>
  
  <pre><code>&lt;input class="required" id="client-searched" data-val="true" 
    name="ClientSearched" data-val-required="Press search!"/&gt;
  &lt;span class="field-validation-valid" data-valmsg-replace="true" 
    data-valmsg-for="ClientSearched"/&gt;
  </code></pre>