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

Invalid validation message in Date/Time Picker

2 Answers 361 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
LUCIAN GOGONEA
Top achievements
Rank 1
LUCIAN GOGONEA asked on 29 Oct 2015, 05:56 PM

We are experiencing an issue with the Kendo ui datetime picker in our MVC Sitefinity application. The issue manifests itself only in IE after a workaround JavaScript function has been applied. The application's default culture is set to fr-CA however in the view the date format needs to be fr-FR. If submit is clicked and the text area of the datetime picker is empty the validation message as set on the model property is displayed correctly, however if any non valid text is entered into the text area then the validation message displayed is: "DateDebut is not a valid date". The workaround function replaces the data-val-date attribute displaying the correct validation message in the French language and as stated works in all browsers but IE.  As show below the kendo culture is set to fr-FR.

 

$(document).ready(function () {
        kendo.culture("fr-FR");
    });
 
   $(function () {
        $("input[data-val-date]").each(function (index, el) {
            var re = new RegExp("The field (.*?) must be a date");
            var string = $(this).attr("data-val-date");
            var m = string.match(re);
            if (m != null && m.length > 1) {
                $(this).attr("data-val-date", string.replace(m[0], "Le champ " + m[1] + " doit être une date (ex: 14/06/2015)"));
            }
 
        });
    });
 
   <div class="form-group" style="width: 100%">
        @Html.LabelFor(m=> m.DateDebut, new { @class = "control-label col-sm-4" })
        <div class="col-sm-3">
            @Html.Kendo().DatePickerFor(m => m.DateDebut).Format("{0:dd/MM/yyyy}").HtmlAttributes(new {@style="width:150px;"})
            @Html.ValidationMessageFor(m => m.DateDebut)
        </div>
    </div>

 

 

2 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 02 Nov 2015, 11:55 AM
Hello LUCIAN GOGONEA,

My assumption is that the applied change is not honored in IE. Unfortunately, I am not sure what exactly could cause the issue in this particular case. I would suggest you try to change the DatePicker widget with regular HTML Input element. If the issue still persists, then the problem is not related to UI for ASP.NET MVC / Kendo UI, but the issue caused by the used client validation framework together with the IE browser.

If the issue is related to the DatePicker widget, please send us a regular ASP.NET MVC demo, as it is not related to Sitefinity, that replicates the problem. Thus we will be able to review the case locally and advice much faster.

Regards,
Georgi Krustev
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
0
LUCIAN GOGONEA
Top achievements
Rank 1
answered on 04 Nov 2015, 03:26 PM

Hi Georgi,

I did replace DatePicker widget with a regular HTML Input element and our function to replace the English validation text with French text works. I was however able to find a solution for the DatePicker validate by adding a javascript library which overrides ​Kendo validation ​messages at the prototype level per chosen language. ​Found @ https://github.com/loudenvier/kendo-global. Kudos to the developer. Our original function is still required when using Chrome, but in IE it did the trick.

 

 ​

Tags
Date/Time Pickers
Asked by
LUCIAN GOGONEA
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
LUCIAN GOGONEA
Top achievements
Rank 1
Share this question
or