MVC 4 date culture issue?

后端 未结 4 819
-上瘾入骨i
-上瘾入骨i 2020-12-01 08:08

I am using MVC 4 and am wondering if there is a bug in the Datetime culture info?

I am trying to get Australian dates to work (dd/MM/yyyy), but it keeps saying that

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-01 08:54

    Accepted answer is not up to date. My finally working solution:

    $(function () {
        $.validator.methods.date = function (value, element) {
            return this.optional(element) || moment(value, "DD.MM.YYYY", true).isValid();
        }
    });
    

    You have to include before:

    @Scripts.Render("~/Scripts/jquery-3.1.1.js")
    @Scripts.Render("~/Scripts/jquery.validate.min.js")
    @Scripts.Render("~/Scripts/jquery.validate.unobtrusive.min.js")
    @Scripts.Render("~/Scripts/moment.js")
    

    You can install moment.js using:

    Install-Package Moment.js
    

提交回复
热议问题