ASP MVC DateTime validation error

前端 未结 5 1676
轮回少年
轮回少年 2021-01-26 08:28

In asp.net MVC 5, I have a form that displays data from a DTO object:

public class FieldDTO
{
    [DataType(DataType.DateTime)]
    [DisplayFormat(ApplyFormatInE         


        
5条回答
  •  -上瘾入骨i
    2021-01-26 09:13

    For me just have this code to ovewrite the default Jquery datetime validation:

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

提交回复
热议问题