KendoDatePicker Multiple Formats

8.8k views Asked by At

How to accept multiple formats in KendoDatePicker?

For example, to declare multiple formats similar to this (if format were to accept an array).

this.$('#dtToDate').kendoDatePicker({
            value: new Date(),
            min: new Date(1950, 0, 1),
            max: new Date(2049, 11, 31),
            format: ["MM-dd-yyyy", "MM/dd/yyyy"]
        });

In order to accept a date with format of 12-10-2013 or 12/10/2013.

1

There are 1 answers

0
G-Man On BEST ANSWER

What you are looking for is parseFormat. format only accepts 1 value.

parseFormat is an array that

Specifies the formats, which are used to parse the value set with value() method or by direct input. If not set the value of the options.format and options.timeFormat will be used. Note that value of the format option is always used

Reference http://docs.kendoui.com/api/web/datetimepicker#configuration-parseFormats

and jsfiddle example

$("#sampleDate").kendoDatePicker({
    format: "MM-dd-yyyy",
    parseFormats: ["MM-dd-yyyy", "MM/dd/yyyy"]
});

http://jsfiddle.net/85DUe/

the example will accept values in both the MM-dd-yyyy and MM/dd/yyyy and convert them to what is specified in format which is MM-dd-yyyy