Answers for "input date field disable past dates"

1

html set input type date to disable previous dates

$(function(){
    var dtToday = new Date();
    
    var month = dtToday.getMonth() + 1;
    var day = dtToday.getDate();
    var year = dtToday.getFullYear();
    if(month < 10)
        month = '0' + month.toString();
    if(day < 10)
        day = '0' + day.toString();
    
    var maxDate = year + '-' + month + '-' + day;
    alert(maxDate);
    $('#txtDate').attr('min', maxDate);
});
Posted by: Guest on March-06-2020
-2

disable past date in inpit date picker

$(function(){
    var dtToday = new Date();
    
    var month = dtToday.getMonth() + 1;
    var day = dtToday.getDate();
    var year = dtToday.getFullYear();
   
    $('#txtDate').attr('min', maxDate);
});
Posted by: Guest on January-27-2021

Code answers related to "input date field disable past dates"

Browse Popular Code Answers by Language