MVC 4 how to validate a non-US date with client validation?

后端 未结 4 1706
借酒劲吻你
借酒劲吻你 2020-12-03 08:07

I have a situation where I am having trouble with the client side validation of a datetime field. When I try to submit it keeps telling me the date is invalid (27/7/2013).

4条回答
  •  無奈伤痛
    2020-12-03 08:42

    Try with this,

    View

    @Html.LabelFor(m => m.DOB) @Html.TextBoxFor(m => m.DOB, new { @Formate = "dd/MM/yyyy" }) @Html.ValidationMessageFor(m => m.DOB)

    Model

    [DisplayName("Date Of Birth")][DataType(DataType.Date)]
    public DateTime DOB { get; set; }
    

提交回复
热议问题