EasyUI Forum
September 14, 2025, 09:58:07 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Disable holidays and weekends on calendar (datebox)  (Read 6996 times)
jjosotoro
Newbie
*
Posts: 4


View Profile
« on: March 02, 2015, 05:01:06 AM »

hello.

This code uses the validator property of the calendar control of a datebox; to use it only on a calendar just change the line:

Code:
$('#MyDateBox').datebox().datebox('calendar').calendar({

for this:

Code:
$('#MyCalendar').calendar({

To disable especific dates:

Code:
$(function(){
var NoValDates = ["01/01/2015", "12/01/2015", "23/03/2015", "02/04/2015", "03/04/2015", "01/05/2015", "18/05/2015", "08/06/2015", "15/06/2015", "29/06/2015", "20/07/2015", "07/08/2015", "17/08/2015", "12/10/2015", "02/11/2015", "16/11/2015", "08/12/2015", "25/12/2015"];
var x = NoValDates.length;
 $('#MyDateBox').datebox().datebox('calendar').calendar({
   validator: function(date){
    for (j=0;j<x;j++){
     var d = NoValDates[j].slice(0,2);
     var m = NoValDates[j].slice(3,5)-1;
     var y = NoValDates[j].slice(6,10);
       if(date.getDate()==d  && date.getMonth()==m && date.getFullYear()==y){
return false;
       }
    }

    if(date.getDay()==0 || date.getDay()==6){return false;}else{return true;}; //disables weekends
    return true;
   }
  });
});

The date format used in this code is dd/MM/yyyy.

regards.
« Last Edit: March 24, 2015, 04:42:45 AM by jjosotoro » Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!