disable few dates from calendar javascript

Solutions on MaxInterview for disable few dates from calendar javascript by the best coders in the world

showing results for - "disable few dates from calendar javascript"
Jenna
03 Jan 2017
1<head>
2  <link rel="stylesheet" href="http://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
3  <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
4  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
5</head>
6
7<body>
8<input required class="datepicker" id="datepicker1" type="text" name="date" placeholder="Collection Date" autocomplete="off">  
9</body>
10  
11<script>
12// datepicker validation
13$(document).ready(function() {
14
15    var dates1 = ["20/05/2021", "21/05/2021", "22/05/2021"];
16
17    function DisableDates1(date1) {
18        var string = jQuery.datepicker.formatDate('dd/mm/yy', date1);
19        return [dates1.indexOf(string) == -1];
20    }
21
22    jQuery("#datepicker1").datepicker({
23        minDate: 2,
24        dateFormat: "yy-mm-dd",
25        changeMonth: true,
26        numberOfMonths: 1,
27        changeYear: true,
28
29        beforeShowDay: DisableDates1,
30
31        onClose: function(selectedDate, inst) {
32            var minDate = new Date(Date.parse(selectedDate));
33            minDate.setDate(minDate.getDate() + 2);
34            jQuery("#datepicker2").datepicker("option", "minDate", minDate);
35        }
36    });
37});
38</script>