admin管理员组文章数量:1328022
HTML5 type=time
has a property disabled which disables the field, but is there any specific way to disable only the hours or only the minutes from the field?
<input type='time' />
HTML5 type=time
has a property disabled which disables the field, but is there any specific way to disable only the hours or only the minutes from the field?
<input type='time' />
Share
Improve this question
edited Aug 29, 2019 at 8:28
sSD
asked Aug 29, 2019 at 8:01
sSDsSD
2921 gold badge2 silver badges17 bronze badges
2
- What did u try ? – user4431269 Commented Aug 29, 2019 at 8:05
- @PhilAndelhofs, was thinking to block using css, but could not get hold of the dom element specific to the hours or minutes entry field. – sSD Commented Aug 29, 2019 at 8:12
2 Answers
Reset to default 6You can definitely lock the minutes so they can't be changed and only hours can be adjusted, just change the step:
For example:
<input type='time' step='3600'/>
<input type='time' step='3600'/>
To acplish only using minutes, you can technically do this by maxing and mining the time:
<input type='time' max='00:59' min='00:00'/>
step
is the attribute you are looking for.
The step
attribute indicate what the minimum increment should be in seconds. If set to 60, the increment will always be 60 seconds - in other words, seconds cannot be changed. To make the minutes too cannot be changed, use step="3600"
.
<form>
<label for="appt-time">Choose an appointment time: </label>
<input id="appt-time" type="time" name="appt-time" step="3600">
</form>
版权声明:本文标题:javascript - Is there a way to disable the minutes or hours selection only for html5 type=time? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742243670a2438995.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论