我需要能够输入日期,但需要 jQuery Mobile 日期选择器才能接受 MM/YYYY 数据。解决这个问题会很棒。谢谢。
这就是我所拥有的...
看法:
<h3>Search Dates</h3>
<div data-role="fieldcontain">
<div class="editor-label">
@Html.LabelFor(m => m.SearchBeginDate)
</div>
<div class="editor-field">
@Html.TextBoxFor(m => m.SearchBeginDate)
@Html.ValidationMessageFor(m => m.SearchBeginDate)
</div>
<div class="editor-label">
@Html.LabelFor(m => m.SearchEndDate)
</div>
<div class="editor-field">
@Html.EditorFor(m => m.SearchEndDate)
@Html.ValidationMessageFor(m => m.SearchEndDate)
</div>
<br />
</div>
模型:
[Required]
[Display(Name = "Begin Date")]
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:MM/yyyy}")]
public DateTime SearchBeginDate { get; set; }
[Required]
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:MM/yyyy}")]
[Display(Name = "End Date")]
public DateTime SearchEndDate { get; set; }