如何验证 .Net MVC 中的 Kendo 日期不应超过今天的日期?

How to validate Kendo Date in .Net MVC should not exceeding today's date ?

如何验证 Kendo .Net MVC 中的日期不应超过今天的日期? 并且日期格式为 MMDDYYYY,上面没有时间。

出生日期不能超过今天,只需要日期即可。

<div class="col-sm-7">
                            @(Html.Kendo().DatePickerFor(m => m.BirthDate))
                            <span asp-validation-for="BirthDate" class="text-danger"></span>
                        </div>

这就是我们使用的。如果你允许死人,就把 Min 干掉:)

@(Html.Kendo().DatePickerFor(model => model.BirthDate)
              .Enable(false)  // or some condition
              .Format("MM/dd/yyyy")
              .Min(new DateTime(1900, 1, 1))
              .Max(DateTime.Today)
)

https://demos.telerik.com/aspnet-mvc/datepicker/rangeselection

另外,我的模型有:

[DataType(DataType.Date)]
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:MM/dd/yyyy}")]
public DateTime? BirthDate { get; set; }