Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Hero_78's avatar

daterangepicker disable dat

i have this script to user can reserve date but i want to disable the reserved date but he don t work can you help me ?

let days = []; // Initialize days array

$(document).ready(function() { // Retrieve the reserved dates passed from the server-side const reservedDates = @json($reservedDates).map(date => formatDate(new Date(date)));

  // Log the reserved dates array to the console
  console.log("Reserved Dates:", reservedDates);

  $('#dateRnage').dateRangePicker({
      singleMonth: true,
      showShortcuts: false,
      showTopbar: false,
      startDate: new Date(), // Start date is today
      isInvalidDate: function(date) {
          // Format the date to 'YYYY-MM-DD'
          const formattedDate = formatDate(date);
          
          // Log the date being checked to the console
          console.log("Checking Date:", formattedDate);

          // Disable the date if it matches any reserved date
          const isDisabled = reservedDates.includes(formattedDate);
          console.log(`Date ${formattedDate} is ${isDisabled ? 'disabled' : 'enabled'}`);
          return isDisabled;
      },
 });
0 likes
1 reply
Snapey's avatar

please format the code in your question, and tell us what date picker this is

Please or to participate in this conversation.