title: Client validation for EditorFor in asp.net mvc
body: <p>I have an EditorFor template for date which consists of three dropdowns(mm,dd,yyyy). Below is the class for the same which consists of some validations working fine</p>
  
  <pre><code>public class DateDDL
      {
          public IEnumerable&lt;SelectListItem&gt; Days { get; set; }
          public IEnumerable&lt;SelectListItem&gt; Months { get; set; }
          public IEnumerable&lt;SelectListItem&gt; Years { get; set; }
  
          [Attributes.DateDDLValidation("Day", "Month", "Year", ErrorMessage = "Select day")]
          public int Day { get; set; }
  
          [Attributes.DateDDLValidation("Day", "Month", "Year", ErrorMessage = "Select month")]
          public int Month { get; set; }
  
          [Attributes.DateDDLValidation("Day", "Month", "Year", ErrorMessage = "Select year")]
          public int Year { get; set; }
  }
  </code></pre>
  
  <p>But now i have to write a validation in model class for the same editorfor which is something like below</p>
  
  <pre><code>  public partial class User
      {
          public DateDDL DOBDDL { get; set; }
  
          [pmrms.Attributes.DateGreaterThanToday(ErrorMessage="testting")]
          public DateDDL JoinedOnDDL { get; set; }
  }
  </code></pre>
  
  <p>But client validation for this is not able set or not working. GetClientValidationRules method is not loading in custom validator class</p>
  
  <pre><code> protected override ValidationResult IsValid(object value, ValidationContext validationContext)
          {
              return new ValidationResult(ErrorMessage);
          }
          public IEnumerable&lt;ModelClientValidationRule&gt; GetClientValidationRules(ModelMetadata metadata, ControllerContext context)
          {
              return new[] { new ModelClientValidationDateGreaterThanToday(ErrorMessage) };
          }
          public class ModelClientValidationDateGreaterThanToday : ModelClientValidationRule
          {
              public ModelClientValidationDateGreaterThanToday(string errorMessage)
              {
                  ErrorMessage = errorMessage; 
              }
          }
  </code></pre>