Kendo DatePicker fails validation for custom date format

前端 未结 6 1174
孤城傲影
孤城傲影 2021-02-02 11:48

I\'m using Kendo DatePicker to edit a Date field being displayed in a Kendo Grid in my ASP.NET MVC 4 project. In order to have the DatePicker being used for the Date field use c

6条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-02 12:02

    Internally, the date validation rule for ASP.NET MVC (the unobtrusive client validation), uses kendo.parseDate(string) method, which internally will use the predefined date patterns if no format/s is/are defined. I suppose that in your case the default culture is "en-US" and that is why validation fails, because dates with "dd/MM/yyyy" format are considered as not valid. One possible solution is to override the date validation rule (as you did) and parse the string using a specific format. The other option is to set diff culture settings for the page. For instance, the short date format for the "de-DE" culture is "dd/MM/yyyy".

提交回复
热议问题