title: ASP .Net MVC 3 unobtrusive custom client validation
body: <p>I have used the jquery validation plug in for a couple years now but this is my first effort to mixing with MVC 3 unobtrusive validation.</p>
  
  <p>Information on the client side of things is scattered all over the internet and it's hard to find any thing that is deep enough to explain it to people that have not used it yet. I have been burning up Google for an hour now for an example on how to create a custom client side validator.</p>
  
  <pre><code>@Html.TextBoxFor(model =&gt; Model.CCPayment.CardNumber, new { @class = "textInput validateCreditCard", maxLength = "20" })
  
  $(document).ready(function () {
        jQuery.validator.unobtrusive.adapters.add('validateCreditCard', {}, function (value, element) {
          alert('foo');
      });
  });
  </code></pre>
  
  <p>if I run the above code in the bottom of my view it does absolutely nothing. I have even tried jquery.validator.addmethod()  and still nothing. All the client side validation that is emitted from my model validation annotations works fine. </p>
  
  <pre><code>&lt;div class="ctrlHolder"&gt;
                  &lt;label&gt;
                      &lt;em&gt;*&lt;/em&gt;
                      Card Number:
                  &lt;/label&gt;
                  @Html.TextBoxFor(model =&gt; Model.CCPayment.CardNumber, new { @class = "textInput validateCreditCard", maxLength = "20" })
  
                  &lt;p class="field-validation-valid formHint" data-valmsg-for="CCPayment.CardNumber"&gt;&lt;/p&gt;
               &lt;/div&gt;
  </code></pre>