title: Client Side validation for a particular hidden field in Asp.net-MVC
body: <p>I am using data annotation for validation and also using unobtrusive.js for client side validation.</p>
  
  <p>I have several hidden fields that are not validated (and I don't need) by default as per the default setting of jquery.validate.js (ignore: ":hidden").</p>
  
  <p>In my case I just want to validate a particular hidden field and not the all as a result I can't override </p>
  
  <pre><code>                   ***ignore: ":hidden"*** to  ***ignore:[]***.
  </code></pre>
  
  <p>If it is changed then all hidden fields will be considered for validation which is not my requirement.</p>
  
  <p>Have no idea how to enable validation for a particular hidden field.</p>
  
  <pre><code> [ValidDate(ErrorMessage = "This is not a valid date.Please enter date in dd/mm/yyyy format.")]
   public string HiddenSelectedDob { get; set; }
  </code></pre>
  
  <p>Where <code>ValidDate</code> is a custom attribute.</p>
  
  <p>Here I am taking input from the user for the day , month and year from three different dropdowns and for the change event of each drop down the value of the <code>HiddenSelectedDob</code> will be set using jQuery.</p>
  
  <p>Finally on submit this hidden filed should be validate.</p>
  
  <p>I have given a class name to that hidden filed like..</p>
  
  <pre><code>@Html.HiddenFor(m =&gt; m.HiddenSelectedDob, new { @class = "validateAlways" })
  </code></pre>
  
  <p>and override the default setting of jquery.validate.js like </p>
  
  <pre><code>$.validator.setDefaults({ ignore: ":hidden:not(.validateAlways)" });
  </code></pre>
  
  <p>but the result is same. The field is not validating.</p>