I am trying to get the MVC date picker to parse and format dates the same as the ASP.Net date picker does, eg. user enters 1/1/11 and the picker formats it into 1/1/2011.
How do I get the MVC date picker to do this?
Thanks.
3 Answers, 1 is accepted
0
Viktor Tachev
Telerik team
answered on 05 Apr 2016, 09:16 AM
Hello Michael,
In order to specify how the dates are parsed you can configure the parseFormats setting of the picker widget.
Check out the following example that illustrates the approach:
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Feedback Portal
and vote to affect the priority of the items
I was hoping for something better that that as the ASP.Net controls just do it for you. Are there any quirks around the ordering of the date formats or is any order ok?
0
Viktor Tachev
Telerik team
answered on 06 Apr 2016, 12:08 PM
Hi Michael,
You can set the format and parseFormats based on your requirements. One thing to note is that when you set multiple parseFormats the widget will use the first format that can be applied to the value entered by the user. Thus, you should be careful not to use parse formats that can be ambiguous.
For example, lets assume that you have the following setting:
parseFormats: ["MM/dd/yy", "dd/MM/yy"]
If the user enters February 1-st, 2003 like this
1/2/3
the date will be parsed as January 2-nd. This is because the widget cannot guess the date and will use the first parse format.
On the other hand if the input is the following:
15/1/3
The date will be parsed as January 15-th - the first parse format cannot be applied and the widget tries the second one.
Regards,
Viktor Tachev
Telerik
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Feedback Portal
and vote to affect the priority of the items