Reputation: 3492
How to validate Kendo Date in .Net MVC should not exceeding today's date ? And also having the date format as MMDDYYYY with no timings on it.
Date of Birth should not exceed today's date and just need only the date.
<div class="col-sm-7">
@(Html.Kendo().DatePickerFor(m => m.BirthDate))
<span asp-validation-for="BirthDate" class="text-danger"></span>
</div>
Upvotes: 1
Views: 309
Reputation: 12304
This is what we use. Take out the Min if you allow dead people :)
@(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
Also, my model has:
[DataType(DataType.Date)]
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:MM/dd/yyyy}")]
public DateTime? BirthDate { get; set; }
Upvotes: 1