This is a migrated thread and some comments may be shown as answers.

Form DatePicker field format validation error

1 Answer 33 Views
Form
This is a migrated thread and some comments may be shown as answers.
Frans
Top achievements
Rank 1
Veteran
Iron
Frans asked on 16 Apr 2021, 01:25 PM

Hi,

I get a error message 'The field StartDate must be a date.' when I try to set the DatePicker dateformat, like this:

It seems something goes wrong by validating the date value, because of the format.

My code snippet:

   items.Add()
                            .Field(propInfo.Name)
                            .Label(propInfo.Label)
                            .Editor(e =>
                            {
                                e.DatePicker().Format("dd-MM-yyyy");
                            });

How can I solve this easily, on the server side (preferably not jQuery / javascript fix).

1 Answer, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 21 Apr 2021, 10:23 AM

Hello, Frans,

The error you are seeing is triggered by the client side validator. This usually occurs when the client has a different culture than the server and it prevents unexpected formats to be sent to the server side.

To remedy the error, you need to set the client side culture as well as the server side culture to match. We have an article about this at:

https://docs.telerik.com/aspnet-mvc/globalization/overview#matching-cultures

Give this a try and let me know in case the issue persists and in which culture so I can run some test locally.

Look forward to hearing back from you.

Regards,
Martin
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Form
Asked by
Frans
Top achievements
Rank 1
Veteran
Iron
Answers by
Martin
Telerik team
Share this question
or