如何在HTML< input type ="date">中隐藏年份部分.日历面板? [英] How to hide the year part in Html <input type="date"> calendar panel?

查看:985
本文介绍了如何在HTML< input type ="date">中隐藏年份部分.日历面板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以隐藏年份部分html日历面板,仅在日历上显示月份和日期部分.

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

推荐答案

不幸的是,这里没有简单的答案,但是您可以使用另一种方法,通过使用javascript来强制用户仅输入月份和日期.

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

这篇关于如何在HTML&lt; input type ="date"&gt;中隐藏年份部分.日历面板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆