Calendar
Calendar
Validation
Features
Sample
Use this Calendar control to select a date. Notice you won't be able to select weekends.
Description
This sample shows how to set item-validator attribute to a function to determine whether dates
are valid for selection.
Source
ValidationController.cs
using Microsoft.AspNetCore.Mvc;
namespace MvcExplorer.Controllers
{
public partial class CalendarController : Controller
{
public ActionResult Validation()
{
return View();
}
}
}
Validation.cshtml
@{
var today = DateTime.Now.Date;
var minDate = new DateTime(today.Year, 1, 1);
var maxDate = new DateTime(today.Year, 12, 31);
}
@section Scripts{
<script>
function itemValidator(date) {
var weekday = date.getDay();
return weekday != 0 && weekday != 6;
}
</script>
}
<div>
<P>@Html.Raw(CalendarRes.Validation_Text0)</P>
<c1-calendar value="@today" min="@minDate" max="@maxDate" item-validator="itemValidator" width="300px">
</c1-calendar>
</div>
@section Description{
@Html.Raw(CalendarRes.Validation_Text1)
}
Documentation