Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="js-booking">
  <h4 class="text-center">Unavailable Dates (UK Format)</h4>
  
  <ul class="c-dates" id="js-blockout-dates">
    <li class="js-blockout-date" data-date="05/11/2015">05/11/2015</li>
    <li class="js-blockout-date" data-date="20/11/2015">20/11/2015</li>
    <li class="js-blockout-date" data-date="21/11/2015">21/11/2015</li>
  </ul>
  
  <hr>
  
  <form class="booking-form">
    
    <div class="form-group">
      <label for="js-holiday-type">Choose a Holiday Type</label>
      <select class="form-control js-holiday-type">
        <option value="Any">Any</option>
        <option value="Pods">Pods</option>
        <option value="Tents">Tents</option>
        <option value="Touring">Touring</option>
        <option value="Holiday Homes">Holiday Homes</option>
      </select>
    </div>
    
    <div class="form-group">
      <label for="arrival-1">Arrival Date</label>
      <input id="arrival-1" type="text" class="form-control arrival-date datepicker" placeholder="select arrival date">
    </div>
    
    <div class="form-group">
      <label for="departure-1">Departure Date</label>
      <input id="departure-1" type="text" class="form-control departure-date datepicker" placeholder="select departure date">
    </div>

    <div class="form-group">
      <label>Actual Arrival Posted</label>
      <input type="text" class="form-control actual-arrival">
    </div>

    <div class="form-group">
      <label>Actual Departure Posted</label>
      <input type="text" class="form-control actual-departure">
    </div>

    <div>
      <button type="submit" class="btn btn-primary">Submit</button>
    </div>
  </form>
</div>

</div><!-- END .booking -->

<hr>

<div class="js-booking">
  <h4 class="text-center">Unavailable Dates (UK Format)</h4>
  
  <ul class="c-dates" id="js-blockout-dates">
    <li class="js-blockout-date" data-date="05/12/2015">05/12/2015</li>
    <li class="js-blockout-date" data-date="20/12/2015">20/12/2015</li>
    <li class="js-blockout-date" data-date="21/12/2015">21/12/2015</li>
  </ul>
  
  <hr>
  
  <form class="booking-form">
    
    <div class="form-group">
      <label for="holiday-type">Choose a Holiday Type</label>
      <select class="form-control js-holiday-type">
        <option value="Any">Any</option>
        <option value="Pods">Pods</option>
        <option value="Tents">Tents</option>
        <option value="Touring">Touring</option>
        <option value="Holiday Homes">Holiday Homes</option>
      </select>
    </div>
    
    <div class="form-group">
      <label for="arrival-2">Arrival Date</label>
      <input id="arrival-2" type="text" class="form-control arrival-date datepicker" placeholder="select arrival date">
    </div>
    
    <div class="form-group">
      <label for="departure-2">Departure Date</label>
      <input id="departure-2" type="text" class="form-control departure-date datepicker" placeholder="select departure date">
    </div>

    <div class="form-group">
      <label>Actual Arrival Posted</label>
      <input type="text" class="form-control actual-arrival">
    </div>

    <div class="form-group">
      <label>Actual Departure Posted</label>
      <input type="text" class="form-control actual-departure">
    </div>

    <div>
      <button type="submit" class="btn btn-primary">Submit</button>
    </div>
  </form>
</div>

</div><!-- END .booking -->
              
            
!

CSS

              
                body {
  max-width: 33em;
}
form {
  padding: 2em;
}
.unavailable a,
.unavailable .ui-state-default {
    color: #fff !important;
    background-color: red !important;
    background-image : none !important;
}
.booking {
  padding: 1em 2em;
}
              
            
!

JS

              
                $('.js-booking').each(function() {

  var $this = $(this);
  var $blockoutDates = $this.find('.js-blockout-date');

  // Days to be disabled as an array, these are pulled from the DOM
  var unavailableDates = [];

  // if there are any block out dates
  // loop through and add them to unavailableDates
  if ($blockoutDates.length) {
    $blockoutDates.each(function(i) {
      var blockoutDate = $(this).data('date');
      unavailableDates[i] = blockoutDate;
    });
  } else {
    unavailableDates[0] = "";
  }

  // disable dates for holiday homes
  function disableDates(date) {

    var m = date.getMonth();
    var d = date.getDate();
    var y = date.getFullYear();

    // First convert the date in to the dd-mm-yyyy format 
    // Increment the month count by 1 as its 0 based
    var datePickerDate = d + '/' + (m + 1) + '/' + y;

    // Check the holiday type
    if ($this.find('.js-holiday-type').length) {
      var holidayType = $this.find('.js-holiday-type').val();
    } else {
      // the app my not have a select option so grab a hidden value
      var holidayType = $this.find('.js-holiday-type-input').val();
    }
    

    // Check if the date belongs to unavailableDates array
    for (var i = 0; i < unavailableDates.length; i++) {
      // Check if the datePickerDate date is in unavailableDates dates array
      if ($.inArray(datePickerDate, unavailableDates) != -1) {
        return [false, 'unavailable'];
        // If the holiday type is a holiday home block out dates
      } else if (holidayType === "Holiday Homes") {
        var day = date.getDay();
        return [(day != 0 && day != 2 && day != 3 && day != 4)];
      } else {
        return [true];
      }
    }

  }

  $(this).find('.datepicker').each(function() {

    var datepickerId = $(this).attr('id').split('-')[1];

    // Arrival Date Picker
    $(function() {
      $('#arrival-' + datepickerId).datepicker({
        minDate: 0,
        maxDate: '+1y',
        dateFormat: 'dd/mm/yy',
        altFormat: 'yy-mm-dd',
        altField: '.actual-arrival',
        beforeShowDay: disableDates
      });
    });

    // Departure Date Picker
    $(function() {
      $('#departure-' + datepickerId).datepicker({
        minDate: 0,
        maxDate: '+1y',
        dateFormat: 'dd/mm/yy',
        altFormat: 'yy-mm-dd',
        altField: '.actual-departure',
        beforeShowDay: disableDates
      });
    });

  });

});
              
            
!
999px

Console