EasyUI Forum
May 11, 2024, 04:33:39 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: Dynamically disable dates on datebox by setting year, month and fortnight values  (Read 3130 times)
jahangir
Jr. Member
**
Posts: 51



View Profile Email
« on: June 02, 2019, 04:52:59 AM »

I have three comboboxes on a form 'year', 'month' and fortnight, and one datebox

I want to achieve following.

1- for example, if the user selects year = 2019 month = 4 and fortnight = 1 and then select the date the datebox should only show the calendar for the month of April 2019.
2- if fortnight = 1 then only dates from 1 to 15  are enabled and if fortnight = 2  then only dates from 16 to 30 are enabled.
Logged
jahangir
Jr. Member
**
Posts: 51



View Profile Email
« Reply #1 on: June 02, 2019, 10:08:26 PM »

I have solved this way.

Code:
$('#dt').datebox({

    onShowPanel: function () {             
   
var s_day, e_day;
        var year = parseInt($('#cbYear').combobox('getText'));
        var month = parseInt($('#cbMonth').combobox('getValue')) - 1;
        var fortnight = parseInt($('#cbForthnight').combobox('getValue'));

        if (fortnight == 1) {
            s_day = 1;
            e_day = 15;
        } else {
            s_day = 16;
            e_day = new Date(year, month + 1, 0).getDate();
        }

        $(this).datebox('calendar').calendar('moveTo', new Date(year, month, 1));
       
$(this).datebox('calendar').calendar({
            validator: function (date) {
                var d1 = new Date(year, month, s_day);
                var d2 = new Date(year, month, e_day);
                return date >= d1 && date <= d2;
     }

  });

    }
});
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!