禁用 html 输入时间的分钟下拉列表

问题描述 投票:0回答:2

我的 html 中有以下时间输入:

<input id="appt-time" type="time" name="appt-time" value="13:30" />

我想知道如何禁用输入的分钟数或如何将分钟数始终设置为“xx:00”

提前致谢!

html time
2个回答
0
投票

一段时间后,我找到了一个对我有用的解决方案:

html:

<input type="time" step="3600">

CSS:

  input[type="time"]::-webkit-calendar-picker-indicator {
    display: none;
  }

  input[type="time"]::-webkit-inner-spin-button,
  input[type="time"]::-webkit-clear-button {
    display: none;
  }

0
投票

有限制最大有效时间的属性,分钟将被禁用

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/time#setting_maximum_and_minimum_times

<input id="appt-time" type="time" name="appt-time" value="00:30" max="00:60"/>
© www.soinside.com 2019 - 2024. All rights reserved.