<h3>From DatePicker</h3>
@Html.EJ().DatePicker("FromDatePicker").ClientSideEvents(e=> e.Select("onFromSelect"))
<h3>To DatePicker</h3>
@Html.EJ().DatePicker("ToDatePicker").ClientSideEvents(e => e.Select("onToSelect"))
<script>
function onFromSelect(args) {
if (args.date.getDay() != 0) {
this.option("value", new Date(args.date.setDate(args.date.getDate() - args.date.getDay())));
// Changes the date to the previous Sunday’s date.
}
}
function onToSelect(args) {
if (args.date.getDay() != 6) {
this.option("value", new Date(args.date.setDate(args.date.getDate() + (6 - args.date.getDay()))));
// changes the date to the Saturday’s date of the week.
}
}
</script> |
This has worked perfectly!
Much appreciated.
Thanks,
Frankie