我使用带有剃须刀的 ASP.NET MVC 的日期时间选择器,当提交的表单收到验证错误消息时,它不会保留我输入的值,也不会选择器不再工作。发生验证错误后是否可以重用选择器控件?
我对选择器的看法:
<div class="editor-label">
@Html.LabelFor(model => model.StartDateTime)
</div>
<div class="editor-field">
@Html.TextBox("Start", null, new { @class = "date" })
@Html.ValidationMessageFor(model => model.StartDateTime)
</div>
jquery 选择器控件:
<script src="/Scripts/mobiscroll-2.0.1.custom.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
var now = new Date();
$('#Start').scroller({
preset: 'datetime',
minDate: new Date(now.getFullYear(), now.getMonth(), now.getDate()),
theme: 'ios',
display: 'modal',
mode: 'scroller'
});</script>