I've a time picker and when I put lower case characters in, validation is false, like instead of PM if I put pM, I get the following message as in the picture.
Also the validation message is not coming from Data Annotation.
Please let me know.
Thank you
1 Answer, 1 is accepted
0
Georgi Krustev
Telerik team
answered on 31 Mar 2014, 12:46 PM
Hi Niroj,
I posted an answer to the support thread opened on the same subject. Here is a quote of the answer:
Straight up to your questions:
#1: Kendo Validator uses a special mvcdate rule, which internally calls kendo.parseDate to determine whether the input is a valid date. As you can see when no formats are passed, the method will uses a list of formats defined in the current Kendo culture to validate the input. In this case, it successfully parse 10:00 pM as a 10:00 and does not show error message. You can overcome this overriding the mvcdate rule (do this after the grid declaration):
<script>
var originMvcDate = kendo.ui.validator.rules.mvcdate;
kendo.ui.validator.rules.mvcdate = function (input) {
var format = input.attr("data-format");
if (format) {
return kendo.parseDate(input.val(), format);
}
return originMvcDate(input);
}
</script>
The next step is to add a specific format, that the validator will use:
//TimePicker editor cshtml page
...
.HtmlAttributes(new { data_format="hh:mm tt" })
...
#2: The error message defined in DateTypeAttribute is ignored when a unobtrusive attributes are rendered by the ASP.NET MVC framework. The first option to overcome this is to set the error message manually: