0

When I use the JQueryUI datepicker widget on a date field that was created with the following expressive annotation the client side validation is not triggered until I click in some other field, return to the date field and then exit the date field.

 [AssertThat("ResolutionDate<=Today()", ErrorMessage = "Resolution date can not be in the future.")]
 [AssertThat("ResolutionDate>=DateReceived", ErrorMessage = "Resolution date must be after the date received.")]
 [DataType(DataType.Date)]
 public DateTime? ResolutionDate { get; set; }

I'm assuming some sort of event is missed. Any ideas or fixes?

John S
  • 7,909
  • 21
  • 77
  • 145

1 Answers1

1

The solution was to force the field to validate in the onSelect event of the datepicker widget.

$("#ResolutionDate").datepicker({
    showAnim: "slide",
    maxDate: "0",
    onSelect: function () {
        $(this).valid();
    }
});
John S
  • 7,909
  • 21
  • 77
  • 145