MVC model validation for date

前端 未结 4 1812
别跟我提以往
别跟我提以往 2020-11-27 22:42

Is there any default validation for MVC 5 where I can set min and max value of date?

In my model i want date validation

    public class MyClass
             


        
4条回答
  •  迷失自我
    2020-11-27 23:15

    I think just adding the attribute "Range" will work

    [Range(typeof(DateTime), "01/01/1900", "06/06/2079", ErrorMessageResourceType = typeof(Resources.Patient), ErrorMessageResourceName = "DateOfBirth_Range")] 
    

提交回复
热议问题