How to remove the autocomplete in the RadDatePicker and the RadDateTimePicker?

4 posts, 0 answers
  1. Paul Tran
    Paul Tran avatar
    13 posts
    Member since:
    Jul 2009

    Posted 18 May 2010 Link to this post

    Hi,

    I noticed that there's an autocomplete in the RadDatePicker and RadDateTimePicker controls. It is really easy to reproduce, just delete the year in the date and get out of focus, the control will automatically fill it up with some kind of algorithm. 

    Is it possible to turn off this feature?

    Thanks,
    Paul
  2. Daniel
    Admin
    Daniel avatar
    4949 posts

    Posted 21 May 2010 Link to this post

    Hello Paul,

    Unfortunately there is no straightforward way to turn off this functionality. You could override the built-in parsing but I don't recommend that you do this.
    <script type="text/javascript">
        Telerik.Web.UI.RadDateInput.prototype.parseDate = function (value, baseDate)
        {
            if (new Date(value) != "NaN")
                return new Date(value);
            this.set_textBoxValue(value);
        }
    </script>

    Best regards,
    Daniel
    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.
  3. Andrew Zhao
    Andrew Zhao avatar
    11 posts
    Member since:
    Mar 2010

    Posted 06 Aug 2010 Link to this post

    I had the samiliar issue. I added overidden parseDate function as suggested, it wouldn't auto correct the input date. However, it won't accept two-digit year like '7/15/10', how do I make it take both 2-digit and 4-digit year?
    Second question, assume that an invalid date '13/1/2010' enter, the OnError event invokes, then I change to '1/1/2010' by simply deleting '3'. At this moment, I found that no ValueChanging event is triggered. How to capture the changes when delete key pressed?
  4. Daniel
    Admin
    Daniel avatar
    4949 posts

    Posted 12 Aug 2010 Link to this post

    Hello Andrew,

    I had the samiliar issue. I added overidden parseDate function as suggested, it wouldn't auto correct the input date. However, it won't accept two-digit year like '7/15/10', how do I make it take both 2-digit and 4-digit year?
    It is expected that the control won't convert such dates automatically given the fact that the parsing logic is overridden (which is not supported scenario). You should either implement you own parsing algorithm or leave the default functionality intact.

    Second question, assume that an invalid date '13/1/2010' enter, the OnError event invokes, then I change to '1/1/2010' by simply deleting '3'. At this moment, I found that no ValueChanging event is triggered. How to capture the changes when delete key pressed?
    You could handle the onkeydown or onkeyup events.
    <telerik:RadDatePicker runat="server" ID="RadDatePicker1">
        <DateInput onkeydown="myFunction()" />
    </telerik:RadDatePicker>

    Regards,
    Daniel
    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
Back to Top