Is there any way to hide the year part html calendar panel, only show month and day part on the calendar.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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
- jquery ui datepicker day/month only, not year selection
- jQuery UI - Datepicker - Hide year
- Jquery datepicker - only day and month