Set date input field’s max date to today

JavaScript only simple solution

datePickerId.max = new Date().toISOString().split("T")[0];
<input type="date" id="datePickerId" />
// below trick also works! Thanks jymbob for the comment.
datePickerId.max = new Date().toLocaleDateString('en-ca')

Leave a Comment