title: ASP .Net MVC 3: Custom unobtrusive validation
body: <p>I am trying to add a custom unobtrusive validation to my app. It does not seem to run the validation.</p>
  
  <p>Here is my Attribute class:</p>
  
  <pre><code>public IEnumerable&lt;ModelClientValidationRule&gt; GetClientValidationRules(
      ModelMetadata metadata, ControllerContext context)
  {
      yield return new ModelClientValidationRule
      {
          ErrorMessage = ErrorMessage,
          ValidationType = "custrequired"
      };
  }
  </code></pre>
  
  <p>And my JavaScript:</p>
  
  <pre><code>$.validator.addMethod('custrequired', function(value, element, param) {
    return value &amp;&amp; value !== '99:99' &amp;&amp; value !== '9:99';
  });
  
  $.validator.unobtrusive.adapters.add('custrequired', null, function(options) {
    return options.messages['custrequired'] = options.message;
  });
  </code></pre>