how can I remove days from input type date? I added default data:
<input required class="data_inizio" type="date" name="inizio" value="2018-01-31">
But I would to remove previous days before that..
how can I remove days from input type date? I added default data:
<input required class="data_inizio" type="date" name="inizio" value="2018-01-31">
But I would to remove previous days before that..
You could use the min attribute, to only allow future dates. Like so: <input required class="data_inizio" type="date" min="2018-01-31" name="inizio" value="2018-01-31">
. You will only need to replace the min value with a dynamic value which represents the current date. You could use something like php for that: .
So it would become:
<input required id="date-input" class="data_inizio" type="date" min="<?=date('Y-m-d', time())?>" name="inizio" value="2018-01-31">`.
You can find the browser support over here: Browser_compatibility
Or setting the date using javaScript:
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();
if(dd<10) {
dd = '0'+dd
}
if(mm<10) {
mm = '0'+mm
}
today = yyyy + '-' + mm + '-' + dd;
document.getElementById("date-input").setAttribute('min', today);