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

Badly formatted user input

2 Answers 83 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
Henrik
Top achievements
Rank 1
Henrik asked on 26 May 2016, 09:26 AM

Hi,

I have a DatePicker that displays the date nicely in the correct format i.e. "2016-05-26" for May 26, 2016.

 

I would like to handle badly formatted user input, like "160531" which is an allowed way to enter a date in our organisation. I want to take this date and format it correctly with some JS code. The problem is that when I input a date like this I can't get it from the datepicker in my javascript code.

JS Code:

       var date1 = kendo.toString($("#RelevantDate").data("kendoDatePicker").value(), 'd');
        var date2 = $("#RelevantDate").data("kendoDatePicker").value();

both the date1 and the date2 variable are null if I have a date like "160531". With a nicely formatted date everything works.

 

Is there any way to get a badly formatted date out of the datepicker? I want the users to be able to select the date in the picker and to enter the date manually so changing to a textbox input is not an option.

 

Best regards,

Henrik
 

2 Answers, 1 is accepted

Sort by
0
Accepted
Pavlina
Telerik team
answered on 26 May 2016, 11:52 AM
Hi,

You can refer to the sample dojo example below which shows how to parse the input value to the desired format:
http://dojo.telerik.com/OCeQI/3

It should help you achieve your goal.

Regards,
Pavlina
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
Henrik
Top achievements
Rank 1
answered on 27 May 2016, 07:05 AM

Thanks for the prompt reply,

 

Took me a little trial-and-error, but I got it to work as I wanted. Thanks!

 

Henrik

Tags
Date/Time Pickers
Asked by
Henrik
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Henrik
Top achievements
Rank 1
Share this question
or