0

I'm working on a django project, where the user need to pick the dates for applying leaves. So, I have included the below code in my base.html. I have no basic knowledge in javascript but some how i came up how to disable weekends.

<script>

    $(document).ready(function() {
        $('.datepicker').datepicker(
          {
            minDate : 0,
            beforeShowDay : $.datepicker.noWeekends
          }
        );
    });

    </script>

I have list of custom dates in db which are declared as holidays and I want them to be disabled in the datepicker, provided with weekends as disabled too.

  • Did you check this link? [https://stackoverflow.com/questions/15400775/jquery-ui-datepicker-disable-array-of-dates](https://stackoverflow.com/questions/15400775/jquery-ui-datepicker-disable-array-of-dates) – Vanch Sep 05 '18 at 06:10
  • @ChristopheVanassche so, beforeshowDay canbe used twice? – John Richards Sep 05 '18 at 06:10
  • You can find a combination of both in this post: https://stackoverflow.com/questions/501943/can-the-jquery-ui-datepicker-be-made-to-disable-saturdays-and-sundays-and-holid. Just combine the weekend dates and the holidays in 1 array. – Vanch Sep 05 '18 at 06:12
  • @ChristopheVanassche What if the dates are stored in the database? – John Richards Sep 05 '18 at 06:31
  • I'm not familiar with Python, but you could use an ajax call to get the data. Create a file where you get the data from your database, and return it to your call. For example: `$.ajax({ url: 'path/to/server-side/script', /*url*/ data: '', /* post data e.g name=christian&hobbie=loving */ type: '', /* POST|GET */ complete: function(d) { var data= d.response; /* Here you can use the data as you like */ } });` – Vanch Sep 05 '18 at 06:38

0 Answers0