JSFiddle - React, Tailwind, and code Playground

by praveen_jegan

HTML

<input type="date" id="date1" max="" min="" onblur= "setMaxDate()"/>
<input type="date" id="date2" max="" min="" />

JavaScript

function setMaxDate() {
    var d1 = document.getElementById('date1');
    var d2 = document.getElementById('date2');
    var t = d1.value.split("-");
    var date = new Date(parseInt(t[0], 10) + 1, parseInt(t[1], 10), t[2]);
    var maxi = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate();    
    d2.setAttribute("max", maxi);
}