Validation doesn't take into account lower case characters

2 posts, 0 answers
  1. Howard
    Howard avatar
    67 posts
    Member since:
    Nov 2011

    Posted 27 Mar 2014 Link to this post

    Hi Telerik Team,

    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
  2. Georgi Krustev
    Georgi Krustev avatar
    3725 posts

    Posted 31 Mar 2014 Link to this post

    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:

    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):
        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);

    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" })

    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:
    .HtmlAttributes(new { data_format="hh:mm tt", data_val_date="Your error" })
    The other option is to use the approach discussed here.

    I will ask you to continue our conversation in only one thread to avoid any duplication.

    Georgi Krustev
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top