【问题标题】:MVC4 jQuery Mobile DateTime Picker Format to MM/YYYY OnlyMVC4 jQuery Mobile 日期时间选择器格式仅适用于 MM/YYYY
【发布时间】:2012-11-27 20:14:20
【问题描述】:

我需要能够输入日期,但需要 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; }

【问题讨论】:

    标签: jquery asp.net-mvc mobile formatting datepicker


    【解决方案1】:

    使用“日期”的 HTML5 输入类型属性。这将允许本地控制日期和时间。

    <input type="date" />
    

    【讨论】:

      猜你喜欢
      • 2021-05-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-06
      • 2023-03-04
      • 1970-01-01
      • 2014-07-12
      • 2012-05-25
      相关资源
      最近更新 更多