This is a migrated thread and some comments may be shown as answers.
Manually entering date in the textbox of Datepicker
1 Answer 46 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Nikhil Kashyap
Top achievements
Rank 1
Nikhil Kashyap asked on 06 Sep 2010, 07:15 AM
Hi,
I am using the date picker control for choosing dates. Some times user enters dates manually in the datepicker text box control.
In this case, the date is not correct. e.g. if user enters 6/6/11, then it becomes 6/6/1911(when the date picker collapses). which is wrong.

How to avoid the problem?

Regards
Nikhil Kashyap
Customer ID: JT359876

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 06 Sep 2010, 12:36 PM
Hello Nikhil Kashyap,

To achieve your goal you need to modify telerik.datepicker.js file. There is a special variable, which determines the short year cut off, in parseMachineDate static method. Currently it is set to "+10", which means all short dates bigger then 10 will be parsed as "1900 + short year". In order to set after which number, the year should be treated as 1900 year, you need to make the following modification in the js file:
[before]:
parseMachineDate: function (value, format, minDate, maxDate) {
    var year = -1;
    var month = -1;
    var day = -1;
    var hours = 0;
    var minutes = 0;
    var seconds = 0;
    var isPM;
    var shortYearCutOff = "+10"
    var literal = false;

[after]:
parseMachineDate: function (value, format, minDate, maxDate) {
    var year = -1;
    var month = -1;
    var day = -1;
    var hours = 0;
    var minutes = 0;
    var seconds = 0;
    var isPM;
    var shortYearCutOff = "+30" //date 6/6/31 will be parsed as 6/6/1931
    var literal = false;

Next release of the datepicker, will expose this variable in order to allow to the customers to set this value dinamically.

For your convenience I have attached the telerik.datepicker.js file, which includes the required changes.

Best wishes,
Georgi Krustev
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
Tags
Date/Time Pickers
Asked by
Nikhil Kashyap
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or