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

[Solved] How to validate format dd.MM.yyyy as valid

3 Answers 136 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Lukas
Top achievements
Rank 1
Lukas asked on 26 Jun 2012, 01:46 PM
Hi everybody

I'm using ASP.Net MVC 4 (Beta) in C# and Telerik 2012.1.419 and I have some Issues with the client-side validation. Everything is fine except if I change the culture to de-ch the format validation fails. It accepts only slashes ("/") as separators, not dots (".") as Germans use.

That's strange, because I'm using globalization and the datepicker is giving the right format for the different languages (de, fr, it, en).

I hope, somebody can help me.

Thanks

Lukas

3 Answers, 1 is accepted

Sort by
0
FinallyInSeattle
Top achievements
Rank 1
answered on 17 Nov 2012, 12:02 AM
Same problem here.  All languages display fine, but for validation - US works ("mm/dd/yyyy"), French works ("dd/mm/yyyy"), but German doesn't ("dd.mm.yyyy").  Can someone provide some assistance?
0
Lauri
Top achievements
Rank 1
answered on 27 Nov 2012, 11:54 AM
Hi,

Same here, but I added this:

$.validator.methods.date = function (value, element) {
                if (value == undefined) { return false; }
                return this.optional(element) || kendo.parseDate(value);
            };

and the problem was solved. I hope this helps.

Please notice I use Kendo too, but perhaps you do also.
Please also remember to add the correct culture to Kendo.
0
Daniel
Telerik team
answered on 30 Nov 2012, 09:32 AM
Hello,

The problem occurs because the jQuery validation does not support globalized dates or numbers. The approach to override the default methods is correct. If Kendo which provides methods to parse dates and numbers based on the current culture is not used, you could check this article which shows an alternate solution.

Kind regards,
Daniel
the Telerik team
Check out the successor of Telerik MVC Extensions - Kendo UI for ASP.NET MVC - and deem it for new ASP.NET MVC development.
Tags
Date/Time Pickers
Asked by
Lukas
Top achievements
Rank 1
Answers by
FinallyInSeattle
Top achievements
Rank 1
Lauri
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or