2017-04-19 70 views
0

當我在使用以下表達性註釋創建的日期字段上使用JQueryUI datepicker小部件時,客戶端驗證不會被觸發,直到我點擊其他字段,返回日期字段,然後退出日期字段。ExpressiveAnnotations和JqueryUI DatePicker不觸發客戶端驗證

[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; } 

我假設某種事件是錯過的。任何想法或修復?

回答

1

解決方案是強制字段在datepicker小部件的onSelect事件中進行驗證。

$("#ResolutionDate").datepicker({ 
    showAnim: "slide", 
    maxDate: "0", 
    onSelect: function() { 
     $(this).valid(); 
    } 
});