
I've set up the DatePicker Format AND added the same format to the ParseFormats functions of "ddd, M/d/yyyy"
The strange thing is that the desired input works, but the validation fires.
For example.
I type "3/10/2013" into the field and tab to the next input. At this point, my input changes to "Sun, 3/10/13" (which is desired), BUT I get the "Field Date must be a date" validation error message.
Do I need to define this format on the view model as well or is something else strange going on?
Here's the source and an image of the issue is attached:
@(Html.Kendo().DatePickerFor(m => m.PickupDate)
.ParseFormats(new string[] {
"ddd, M/d/yyyy",
"ddd, MM/dd/yyyy",
"ddd, M/dd/yyyy",
})
.Format("ddd, M/d/yyyy")
.HtmlAttributes(new { style = "width:110px;" })
)
<
span
class
=
"k-invalid-msg"
data-for
=
"PickupDate"
></
span
>
23 Answers, 1 is accepted
I believe that the problem is related to jquery.validate and its inability to parse date string with "MMM, dd/MM/yyyy" format. I will suggest you check this blog post for more information and an approach how to handle this limitation.
Georgi Krustev
the Telerik team

<script src=
"../../../Scripts/jquery.validate.js"
type=
"text/javascript"
></script>
<script src=
"../../../Scripts/jquery.validate.unobtrusive.js"
type=
"text/javascript"
></script>
<script type=
"text/javascript"
>
$(document).ready(
function
() {
jQuery.validator.addMethod(
'date'
,
function
(value, element, params) {
if
(
this
.optional(element)) {
return
true
;
};
var
result =
false
;
try
{
var date = kendo.parseDate(value, "dd.MM.yyyy");
result =
true
;
if(!date){
result = false;
}
}
catch
(err) {
result =
false
;
}
return
result;
},
''
);
});
</script>

The jQuery Validate is a framework, which is not related to Kendo UI and we do not extend/change/modify. Hence, the one, which decides to use it, will need to overcome its limitations manually. Kendo Validator can be used instead of jQuery Validate.
We defintely will point in our documentation how to handle such problems related to jQuery Validate framework.
Georgi Krustev
the Telerik team

As my colleague Georgi pointed out jquery.validate can't parse the "MMM, dd/MM/yyyy" format. This means that jquery.validate will fail with certain date formats with or without using Kendo UI DatePicker. Since patching open source libraries is beyond the scope of our product we can only suggest workarounds (such as the linked blog post) or using a library which we provide support for (Kendo UI Validator). This in fact was one of the main reasons we implemented our own validation library - to provide tight integration between all parts of the framework.
Regards,
Atanas Korchev
the Telerik team


My code looks like:
<
div
class
=
"control-group"
>
@Html.LabelWithAsteriskFor(model => model.ValidTill)
<
div
class
=
"controls"
>
@(Html.Kendo().DatePickerFor(model => model.ValidTill)
.Name("validTill")
.Format("dd-MM-yyyy")
.ParseFormats(new string[] {"ddMMyyyy"}))
</
div
>
</
div
>

I have the same problem,
I don't think blaming jquery is an answer because it is like saying microsoft mvc's Dll's are a problem.
jquery becomes part of the mvc world and the mvc framework is using its abilities to allow the developer to set his mind in building apps and not doing workarounds .
I don't mind using kendo.validaor but your demos and examples are too basic and seem really hard to assemble.
hope you'll release a hotfix or some other reasonable solution

I have a DatePicker in my inline grid editing.
The following solved it (I am in South Africa that's why ZA)
In my view I added the correct culture as below :
@using CIS.UI.MVC.Models
@using Kendo.Mvc.UI
@model ConditionModel
@{
Culture = "en-ZA";
}
and in my grid
columns.Bound(clause => clause.EffectiveDate).Format("{0:d}");
"Field Date must be a date" validation error is now not popping up anymore
Regards,
Wilma

i have a probleme with datepicher() with kendo , some time it s woking some time no my probleme exactly is that
When I insert the date he only accepts date today, and n ' not accept another value, also if I want the date 09/05/2014 it gives me 09/05/2004, here is my code: public Nullable<System.DateTime> DateD_envoie { get; set; }
public Nullable<System.DateTime> DateReponse { get; set; }
in my view i have this :
column.Bound(a => a.DateD_envoie).Format("{0:dd/MM/yyyy}").EditorTemplateName("Date");
column.Bound(a => a.DateReponse).Format("{0:dd/MM/yyyy}").EditorTemplateName("Date");
in shared/EditorTemplates/Date i have this :
@model DateTime?
@(Html.Kendo().DatePickerFor(m => m).Format("dd/MM/yyyy")) thank you


Hi all,
Interesting topic... I am also struggling big time with this nightmare of dependent jQuery plugins, UI and Telerik controls, etc. I tried to implement the new Globalize.js plugin (which, on its turn, uses the cldr plugin for their content); I did not manage to get it to work.
Frustrated by the lack of any proper documentation for MVC4 and client side validations with different locals (seem pretty basic if you read it like this..) I now will try to implement the Kendo validators.
Meanwhile, if someone has some proper tutorials and or sample project for using the jQuery validation and Globalize.js plugin, please post it here..
Regards,
Ruud

I would suggest you review our Validation help topic, which provides a detailed information how to validate model fields in the Grid and also how to troubleshoot / workaround some of the jQuery Validate limitations (it cannot validate internalized dates): You can use Globalize.js parseDate instead of kendo.parseDate if it is the desired way to go.
Regards,
Georgi Krustev
Telerik

Hi Georgi,
Thanks for your reply. I did use this technique of making my own overrides for the $.validator.methods.date functions.
The issue was that the appropriate globalization files were not updated any more after a UI language change by the user. This has to do with the script bundling; I construct the correct Url to the globalization files by combing the selected UI language and the path in the bundle configuration class. This will work when the user logs in, but not if he changes the languages during the session.
So I moved the links back to the layout view, now it works again. I tried a little bit too much cleanup i guess..

datepicker not working i.e. date is not accepting dd/MM/yyyy format
eg. model is accepting the MM/dd/yyyy format whereas i want the data to be written in dd/MM/yyyy format. i have tried culture and format both on my model as well as editor template side but still no effect. What shall be done now?
Here is my code
model:
[UIHint("Date")]
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
public DateTime? WarrantyEndDate { get; set; }
datetime editor template:
@model DateTime?
@(Html.Kendo().DatePickerFor(m => m).Format("dd/MM/yyyy"))

Hi Georgi,
Thanks for your reply. I did of course study this guide; it is just quite a puzzle to get it in a standards MVC project up and running. Lots of script to include, lots of extra work arounds etc. It takes up quite some time; so I hoped some MVC application would be out there to demonstrate how to handle this. But I guess I will have to do some thinking myself :).
Meanwhile FYI for anyone using JayData; I did run into an issue not Telerik specific; I use the JayData client side framework as my data provider; this component seems to always use the en-US locale. Which makes sense. But, Telerik controls of course will work with the selected locale, which can be an issue if you try to display and edit values directly via JayData. It seems to be an issue with numeric (decimal) values only; dates are working fine. For now, I just set the Telerik controls configuration to "en-US" and that works (you do have to instruct your users to use the . as a decimal seperator). The "asKendoDataSource" method does not solve this as well btw.
Regards,
Ruud

Did you solve this issue? If so do you mind sharing your solution...
Facing the same problem
Regards

Is it just me who thinks that this is a complete nonsense.
Surely a plugin should just work.
Telerik is an expensive product and the amount of work to get it to do anything other than look pretty in a contrived simple example is a complete joke.
I am having issues with this stil on release 2016 Q1
As I already asked in another thread - can you please elaborate a bit more what is the issue that you are facing and what you are trying to do, so we can further assist you?
Thanks for the help!
Regards,
Kiril Nikolov
Telerik

This is a big issue that doesn't seem to be getting resolved. I have lost a day trying to get what is a simple date picker to work. Whenever I use the kendo version I just get blocked by this validation problem. I have tried all of the formatting and the culture variations:
@Html.Kendo().DatePickerFor(model => model.Added)
.Format("dd/MM/yyyy").ParseFormats(new List<string>()
{
"dd/MM/yyyy",
"dd/MM/yy",
"dd MMM yyyy"
})
but it just comes back with validation errors. Once again I find myself ripping out the Telerik solution for a much simpler and working solution from either jquery ui or hand rolled. What should be a simple implementation is, like so many other of their controls, difficult to work with.
Can you please open a separate support request with a sample attached and we will be happy to help.
Regards,
Kiril Nikolov
Telerik by Progress