asp.net MVC - 有没有办法在视图的编辑器中设置 TimeSpan 的最大范围?
asp.net MVC - Is there a way to set a TimeSpan's max range in it's editor in a view?
我想设置最大 TimeSpan
范围,以便只能选择上午 8 点到晚上 8 点。
我正在使用剃须刀,所以我的 html 看起来像这样:
@Html.EditorFor(model => model.BookingEndTime, new { htmlAttributes = new { @class = "form-control" } })
呈现为
是否可以只设置 Html.EditorFor
使其最多只能达到 8 而不是 12?否则,我是否必须使用 [Range]
数据注释?
在 html 属性中设置输入类型和范围
type="time" min="08:00:00" max="20:00:00"
请注意,并非所有浏览器都尊重这些属性。
参考:https://www.w3.org/wiki/HTML/Elements/input/time
对于剃刀
@Html.EditorFor(model => model.BookingEndTime, new { htmlAttributes = new { @class = "form-control", type = "time", min = "08:00:00", max = "20:00:00"} })
我想设置最大 TimeSpan
范围,以便只能选择上午 8 点到晚上 8 点。
我正在使用剃须刀,所以我的 html 看起来像这样:
@Html.EditorFor(model => model.BookingEndTime, new { htmlAttributes = new { @class = "form-control" } })
呈现为
是否可以只设置 Html.EditorFor
使其最多只能达到 8 而不是 12?否则,我是否必须使用 [Range]
数据注释?
在 html 属性中设置输入类型和范围
type="time" min="08:00:00" max="20:00:00"
请注意,并非所有浏览器都尊重这些属性。
参考:https://www.w3.org/wiki/HTML/Elements/input/time
对于剃刀
@Html.EditorFor(model => model.BookingEndTime, new { htmlAttributes = new { @class = "form-control", type = "time", min = "08:00:00", max = "20:00:00"} })