Is there a way to hide (mm-dd) or disable (YYYY-mm-0000) the year input from the field? I tried this, but it shows the actual date. If so I need to show 0000
var year = new Date().getFullYear();
document.getElementById('date').setAttribute("min", year + "-01-01");
document.getElementById('date').setAttribute("max", year + "-12-31");
<input type="date" id="date" />
After searching for an hours,I found jquery datepicker can do the trick.
var date = new Date();
$(function() {
$( "#datepicker" ).datepicker({
dateFormat: "dd-M",
changeMonth: true,
minDate: new Date(date.getFullYear(), 0,1),
maxDate: new Date(date.getFullYear(), 12,31)
});
});
.ui-datepicker-year
{
display:none;
}
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<input type="text" id="datepicker">
you can use https://jqueryui.com/datepicker/ to find out more about jquery datepicker