Linking DateBoxes

The most requested bit of coding for DateBox is to link a pair of DateBoxes in a meaningful way - for instance a check in and check out date. Below is a brief bit of code that does exactly that.

HTML Source Code

<div class="form-group">
  <label for="in_date">Check In Date</label>
  <input id="in_date" data-role="datebox" type="text" data-options='{
    "mode":"calbox",
    "afterToday":true,
    "closeCallback":"linker",
    "closeCallbackArgs":["out_date"]
  }'>
</div>
<div class="form-group">
  <label for="out_date">Check Out Date</label>
  <input id="out_date" data-role="datebox" data-options='{"mode":"calbox"}' type="text">
</div>

jQuery Source Code

function linker(obby, nextDatebox) {
  // Access the returned date
  var setDate = obby.date;
  
  // Add one day to set date
  setDate.adj(2,1);
  // Format the date for min/max attribute
  minDate = this.callFormat('%Y-%m-%d', setDate);
  // Set min date on "next" datebox
  $('#'+nextDatebox).attr('min', minDate);
  // Call datebox method to read new min date
  $('#'+nextDatebox).datebox('applyMinMax');
  // Open "next" datebox
  $('#'+nextDatebox).datebox('open');
}