Q:

Limit a date in input type date

I would like to limit the date so that the user does not have to select a date of less than one year, but I wish that it is done automatically compared to the date of the system. If anyone has ideas I'm grateful.

A:

You can get the current date and subtract an year from the current year and set min attribute 

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 minDate = (year-1) + '-' + month + '-' + day;    
    document.getElementById('dt').setAttribute('min', minDate);
<input type="date"  id="dt">

