簡體   English   中英

ExpressiveAnnotations和JqueryUI DatePicker不觸發客戶端驗證

[英]ExpressiveAnnotations and JqueryUI DatePicker not triggering client side validation

當我在通過以下表達性注釋創建的日期字段上使用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; }

我假設錯過了某種事件。 有什么想法或解決辦法嗎?

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

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM