在MVC 5时间输入字段中设置默认时间

时间:2018-12-01 22:39:36

标签: jquery asp.net-mvc razor

我想在输入框上将默认时间设置为12:00 AM,我尝试了各种方法,但仍然显示空白。

.cshtml

<div class="row">
    <div class="col-sm-6 mb-5">
        <div class="form-group">
            <label class="col-sm-3 col-form-label" label-for="Reminder">Time</label>
            <div class="col-sm-6">
                @Html.TextBoxFor(m => m.Reminder, new { @type = "time", @value = "12:00 AM", @class = "form-control", required = "", @placeholder = "12:00 AM" })
                @Html.ValidationMessageFor(m => m.Reminder, "", new { @class = "text-danger error-text" })
            </div>
        </div>
    </div>
</div>

Time Input field

1 个答案:

答案 0 :(得分:1)

这对我有用:

@Html.TextBoxFor(model => model.time, new { @Type = "time", @Value = "22:15:00" })

尝试:

类型->类型

值->值