Skip to content Skip to sidebar Skip to footer

How Do I Disable Dates Till Current Date? For Input Type Datetime-local

I am using Modal for reminder date for task. The current date and the days before it has to be disabled so that the User can select the pick-up date starting next day inorder to Ma

Solution 1:

You can set min and max values on the input field:

<input type="datetime-local" id="dateInput">

$(document).ready(function(){
    elem = document.getElementById("dateInput")
    var iso = new Date().toISOString();
    var minDate = iso.substring(0,iso.length-1);
    elem.value = minDate
    elem.min = minDate
});

Get the current time in a recognised ISO format (you have to trim the zone data off the end, which is annoying), then set that as the input value and the input min.

https://jsfiddle.net/w8qgj543/24/


Post a Comment for "How Do I Disable Dates Till Current Date? For Input Type Datetime-local"