0

I have used Kendo Datepicker (kendo-date-picker)into one of my projects and now I want to restrict the date selection into current month. Yes, I can do it programmatically, but I want to know whether is there any configuration option to restrict the date selection into current month.

For example, if I am in April 2015, I should not be able to select any date outside of April 2015.

Foyzul Karim
  • 4,252
  • 5
  • 47
  • 70
  • Are you using Razor or Javascript? – chiapa Apr 13 '15 at 14:30
  • The Kendo Datepicker has a `min` and a `max` setting that limits the selectable dates, as you probably know. However, you must calculate those min and max dates. There is no setting for "currentMonth" or anything like it. – chiapa Apr 14 '15 at 16:16

2 Answers2

0

You can try this way:

 $(document).ready(function() {
     // JavaScript counts months from 0 to 11. January is 0. December is 11.

     var date = new Date();
     var firstDay = new Date(date.getFullYear(), date.getMonth(), 1);
     var lastDay = new Date(date.getFullYear(), date.getMonth() + 1, 0);

     $("#datepicker").kendoDatePicker({
      min: firstDay,
      max: lastDay
     });
});

See this Demo

111
  • 1,779
  • 1
  • 12
  • 15
  • its not acceptable. because you need to calculate the end date manually for each of the months. I didn't want this. thanks for your reply. – Foyzul Karim Apr 13 '15 at 08:58
  • see this http://stackoverflow.com/questions/13571700/get-first-and-last-date-of-current-month-with-javascript-or-jquery – 111 Apr 13 '15 at 09:17
0

You can override the style to hide the other month dates.

.k-other-month {
    visibility: hide;
}
Huy
  • 760
  • 5
  • 3