简体   繁体   English

如何在HTML时间表中禁用/灰显特定小时

[英]How can I disable / greyout specific hour in HTML time form

I have a booking form and I want to grey-out/disable those hours/times that is selected by customers already. 我有一个预订表格,我想要灰色/禁用客户已经选择的那些小时/时间。

So that the next person book a different time. 这样下一个人预定了不同的时间。 I am not quite sure how to achieve this. 我不太清楚如何实现这一目标。 I have seen disable time range example but I don't know how to link it to this form and make it work. 我见过禁用时间范围示例,但我不知道如何将它链接到此表单并使其工作。 I haven't found any other useful resources around targeting this issue. 我没有找到针对此问题的任何其他有用资源。

 <div class="form-group"> <label for="time">Time</label> <input type="time" name="time" class="form-control" required> </div> 

Unfortunately that's not a part of the <input type="time"> API. 不幸的是,这不是<input type="time"> API的一部分。 You can set a single min= and max= per time element, but that's more or less it. 您可以设置单个min=max=每个时间元素,但这或多或少。

You could, however, maybe leverage the setCustomValidity() API to add an error message saying that the particular time chosen is reserved already if the user tries that. 但是,您可以利用setCustomValidity() API添加一条错误消息,指出如果用户尝试选择的特定时间已经保留。

(However, don't forget to validate the user's entry also on the server side. :) ) (但是,不要忘记在服务器端验证用户的条目。:))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM