I wanted to disable all past date before current date, not with current date. I am trying by bootstrap datepicker library \"bootstrap-datepicker\" and using following code:<
Try it :
$(function () {
$('#datetimepicker').datetimepicker({ minDate:new Date()});
});
<script type="text/javascript">
$('.datepicker').datepicker({
format: 'dd/mm/yyyy',
todayHighlight:'TRUE',
startDate: '-0d',
autoclose: true,
})
Disable all past date
<script type="text/javascript">
$(function () {
/*--FOR DATE----*/
var date = new Date();
var today = new Date(date.getFullYear(), date.getMonth(), date.getDate());
//Date1
$('#ctl00_ContentPlaceHolder1_txtTranDate').datepicker({
format: 'dd-mm-yyyy',
todayHighlight:'TRUE',
startDate: today,
endDate:0,
autoclose: true
});
});
</script>
Disable all future date
var date = new Date();
var today = new Date(date.getFullYear(), date.getMonth(), date.getDate());
//Date1
$('#ctl00_ContentPlaceHolder1_txtTranDate').datepicker({
format: 'dd-mm-yyyy',
todayHighlight:'TRUE',
minDate: today,
autoclose: true
});
You can simply add data attribute in html input tag:
In rails html :
<%= form.text_field :appointment_date, 'data-provide': 'datepicker', 'data-date-start-date': "+0d" %>
HTML :
<input data-provide="datepicker" data-date-start-date="+0d" type="text" name="appointment_date" id="appointment_date">
You can find your solution in this link below: https://codepen.io/ahmetcadirci25/pen/NpMNzJ
Thats work for me.
My code:
var date = new Date();
date.setDate(date.getDate());
$('#datetimepicker1').datetimepicker({
isRTL: false,
format: 'dd.mm.yyyy hh:ii',
autoclose: true,
language: 'tr',
startDate: date
});
Here it is
<script>
$(function () {
var date = new Date();
date.setDate(date.getDate() - 7);
$('#datetimepicker1').datetimepicker({
maxDate: 'now',
showTodayButton: true,
showClear: true,
minDate: date
});
});
</script>