7

Is there any way to hide the year part html calendar panel, only show month and day part on the calendar.

koory1st
  • 135
  • 1
  • 2
  • 8
  • Possible duplicate of [Is there any way to change input type="date" format?](https://stackoverflow.com/questions/7372038/is-there-any-way-to-change-input-type-date-format) – joshua miller Feb 08 '18 at 08:07

1 Answers1

10

Unfortunately there's no easy answer, however you can use an alternative method to force the user to enter only month and date by using javascript.

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' />

The above code locks the year to current year, so the user will only be able to enter the month and the date.


If you still want to try the hard way, read these articles

Roshana Pitigala
  • 8,437
  • 8
  • 49
  • 80