I'm using datepicker and i like people not be able to select date and time previous to the present day. I used "minDate: 0" to disable the past date but is there a way to disable past time. For example, if the current time is 5am, i do not want people to select 3 or 4 am of the same day.
This is my code:
var dt;
dt =
$('#datetimepicker3').datetimepicker({
inline:true,
minDate: 0,
format:'m/d/Y H:i',
formatDate:'d/m/Y'
});
In the Flutter date range picker, you can enable or disable the past dates by using the enablePastDates property of the calendar. When setting the enablePastDates property value as false, you can't able to select the past dates.
To disable a datepicker in jQuery UI we will be using disable() method which is discussed below: jQuery UI disable() method is used to disable the datepicker. Parameters: This method does not accept any parameters.
To disable the past and future dates, we have to use the isValidDate property of the react-datetime.
if we want to change the date format form yyyy-mm-dd to dd-mm-yyyy than we just simply update on format parameter. after applying this parameter we can easily disable future dates in our datepicker of web form.
Declare dateToday
variable and use Date()
function to set it.
Then use that variable to assign to minDate
which is parameter of datepicker
.
var dateToday = new Date();
$(function() {
$( "#datetimepicker3" ).datepicker({
numberOfMonths: 3,
showButtonPanel: true,
minDate: dateToday
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With