title: Add MVC3 unobtrusive validation (addMinMax)
body: <p>I have such attribute:</p>
  
  <pre><code>public class AgeRangeAttribute:ValidationAttribute,IClientValidatable
      {
  public int MinAge { get; set; }
  
          public int MaxAge { get; set; }
  
  public IEnumerable&lt;ModelClientValidationRule&gt; GetClientValidationRules(ModelMetadata metadata, ControllerContext context)
          {
              ModelClientValidationRule rule = new ModelClientValidationRule
                                                  {
                                                      ErrorMessage = ErrorMessage,
                                                      ValidationType = "agerange"
                                                  };
              if (MinAge != int.MinValue)
              {
                  rule.ValidationParameters.Add("minage", DateTime.Now.AddYears(-MinAge).ToShortDateString());
              }
              if(MaxAge != int.MinValue)
              {
                  rule.ValidationParameters.Add("maxage", DateTime.Now.AddYears(-MaxAge).ToShortDateString());
              }
              yield return rule;
          }
  }
  </code></pre>
  
  <p>and JS validator representation:</p>
  
  <pre><code>jQuery.validator.addMethod("agerangemin", function (value, element, param) {
      var date = setDate(new Date(),value);
      var expected = setDate(new Date(), param);
      return date &lt;= expected;
  });
  
  jQuery.validator.addMethod("agerangemax", function (value, element, param) {
      var date = setDate(new Date(), value);
      var expected = setDate(new Date(), param);
      return date &gt; expected;
  });
  
  jQuery.validator.addMethod("agerangemaxmin", function (value, element, param) {
      var date = setDate(new Date(), value);
      var expectedMin = setDate(new Date(), param[1]);
      var expectedMax = setDate(new Date(), param[0]);
      return date &lt;= expectedMin &amp;&amp; date &gt; expectedMax;
  });
  
  
  jQuery.validator.unobtrusive.adapters.addMinMax("agerange", "agerangemin", "agerangemax", "agerangemaxmin");
  </code></pre>
  
  <p>and this js doesn't work (no exceptions... may be dead&amp; :) )</p>
  
  <p>but this works fine:</p>
  
  <pre><code>jQuery.validator.addMethod("agerange", function (value, element, param) {
      var date = new Date();
      date = setDate(date, value);
      var expected = setDate(new Date, param);
      return date &lt;= expected;
  });
  
  jQuery.validator.unobtrusive.adapters.addSingleVal("agerange", "minage");
  </code></pre>
  
  <p>Whats wrong with it? Where is mistake?</p>