Last active
February 5, 2018 16:01
-
-
Save igoralves1/9c8d4b458b9075de5c9a361be871527d to your computer and use it in GitHub Desktop.
Setup a bootstrap datepicker Synchronized dt_start and dt_end
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#http://makitweb.com/how-to-add-datepicker-in-bootstrap/ | |
#https://uxsolutions.github.io/bootstrap-datepicker/?markup=input&format=&weekStart=&startDate=&endDate=&startView=0&minViewMode=0&maxViewMode=4&todayBtn=false&clearBtn=false&language=en&orientation=auto&multidate=&multidateSeparator=&keyboardNavigation=on&forceParse=on#sandbox | |
#https://github.com/uxsolutions/bootstrap-datepicker/blob/master/docs/options.rst | |
#https://bootstrap-datepicker.readthedocs.io/en/latest/options.html#startdate | |
#Sync dt_start with dt_end | |
<div class="form-group"> | |
<label class="form-check-label">Date Range<br> | |
<div> | |
<div id="event_period"> | |
<input id='dt_start' data-date-start-date="-Infinity" style="width:100px;margin: 0em 2em 1em 0em;" type="text" class="datepicker picker-only" readonly placeholder="Select date" data-provide="datepicker" data-date="<?php echo date("Y-m-d"); ?>" value="<?php echo date("Y-m-d"); ?>" data-date-format="yyyy-mm-dd" />To | |
<input id='dt_end' data-date-end-date="Infinity" style="width:100px;margin: 0em 2em 1em 2em;" type="text" class="datepicker picker-only" readonly placeholder="Select date" data-provide="datepicker" data-date="<?php echo date("Y-m-d"); ?>" value="<?php echo date("Y-m-d"); ?>" data-date-format="yyyy-mm-dd" /> | |
</div> | |
</div> | |
</label> | |
</div> | |
$('#dt_start').datepicker() | |
.on('changeDate', function(e) { | |
var dt_start = $('#dt_start').datepicker('getDate'); | |
$('#dt_end').datepicker('setStartDate', dt_start); | |
}); | |
$('#dt_end').datepicker() | |
.on('changeDate', function(e) { | |
var dt_end = $('#dt_end').datepicker('getDate'); | |
$('#dt_start').datepicker('setEndDate', dt_end); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment