Toggle navigation
Bootsnipp
Bootstrap
For
CSS Frameworks
Bootstrap
Foundation
Semantic UI
Materialize
Pure
Bulma
References
CSS Reference
Tools
Community
Page Builder
Form Builder
Button Builder
Icon Search
Dan's Tools
Diff / Merge
Color Picker
Keyword Tool
Web Fonts
.htaccess Generator
Favicon Generator
Site Speed Test
Snippets
Featured
Tags
By Bootstrap Version
4.1.1
4.0.0
3.3.0
3.2.0
3.1.0
3.0.3
3.0.1
3.0.0
2.3.2
Register
Login
"Bootstrap Datepicker with Past, Present and Future"
Bootstrap 3.3.0 Snippet by
dvinodeluru
3.3.0
jQuery
datepicker
Preview
HTML
JS
View Full Screen
Forked from
Fork
Fork this
Parent
1.3K
 
0 Fav
Post to Facebook
Tweet this
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.7.1/css/bootstrap-datepicker.min.css" rel="stylesheet" type="text/css" /> <div class="container"> <div class="row"> <div class="form-group from-date col-sm-4"> <label for="startDate"><b>Past</b></label> <input type="text" id="date-restriction-from" class="form-control pickdate" name="start" value="" placeholder="ex: 01 January 1900" onkeydown="return false"/> </div> <div class="form-group from-date col-sm-4"> <label for="startDate"><b>Present</b></label> <input type="text" id="date-restriction-now" class="form-control pickdate" name="start" value="" placeholder="ex: 01 January 1900" onkeydown="return false"/> </div> <div class="form-group to-date col-sm-4"> <label for="endDate"><b>Future</b></label> <input type="text" class="form-control pickdate" id="date-restriction-to" name="end" value="" placeholder="ex: 01 January 1900" onkeydown="return false"/> </div> </div> </div> <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.7.1/js/bootstrap-datepicker.min.js" type="text/javascript"></script>
$(function (){ var date = new Date(); var today = new Date(date.getFullYear(), date.getMonth(), date.getDate()); var daysback = new Date(date.getFullYear(), date.getMonth(), date.getDate() - 30); $('#date-restriction-from').datepicker({ autoclose: true, endDate: today, format: 'dd MM yyyy' }).datepicker('setDate', daysback); $('#date-restriction-now').datepicker({ autoclose: true, startDate: today, format: 'dd MM yyyy' }).datepicker('setDate', today); $('#date-restriction-to').datepicker({ autoclose: true, endDate: new Date(), format: 'dd MM yyyy' }).datepicker('setDate', today); $('.icon-arrow-left').addClass('glyphicon glyphicon-chevron-left'); $('.icon-arrow-right').addClass('glyphicon glyphicon-chevron-right'); });
Related:
See More
Free Template
Vue Material Dashboard
144.2K
200
Simple Datepicker with moment.js
Questions / Comments:
Post
Posting Guidelines
Formatting
- Now
×
Close
Donate
BTC: 12JxYMYi6Vt3mx3hcmP3B2oyFiCSF3FhYT
ETH: 0xCD715b2E3549c54A40e6ecAaFeB82138148a6c76