If you want to disable weeks in a datepicker using jQuery dynamically then first store weeks date in a array variable. For example:
<script type="text/javascript"> var array = ["2018-11-11","2018-11-12","2018-11-13","2018-11-14","2018-11-15","2018-11-16","2018-11-17"]; </script>
Now you can disable weeks in a datepicker.
Example code:
<script type="text/javascript"> $(function () { $("#datepicker").datepicker({ format: "dd/mm/yy", showOtherMonths: true, selectOtherMonths: true }); }); var array = ["2018-11-11","2018-11-12","2018-11-13","2018-11-14","2018-11-15","2018-11-16","2018-11-17"]; $('#datepicker').datepicker({ beforeShowDay: function(date){ var string = jQuery.datepicker.formatDate('yy-mm-dd', date); return [ array.indexOf(string) == -1 ] } }); </script>
Hope it will be helpful for you.
Question and answer is powered by AnsPress.io