Date input box takes the current month and year by default if the only date is provided

2 posts, 0 answers
  1. Sudhanshu
    Sudhanshu avatar
    3 posts
    Member since:
    Aug 2010

    Posted 27 Sep 2010 Link to this post

    Hi,
    I have encountered one problem in telerik rad date picker.If Only date is provided in date picker input box ,automatically it takes the current month and current year as other values when the focus is out from the DateInput box.
    In the attached file I have put 9 in the "End field" and took the cursor out of the box then it took 9/9/2010 by default.

    In this case 9 and 2010 is the current month and the current year.Please let me know how to overcome this problem.

    Steps to reproduce:
    Click on any of input box(not on datepicker)
    type in the any value(less than 30) in the input box
    and move the cursor out of the box;see it takes the current month and year by default.

    Expected: It should highlight the input box as it does when 0 is keyed in

    regards
    Sudhanshu
  2. Dimo
    Admin
    Dimo avatar
    8472 posts

    Posted 28 Sep 2010 Link to this post

    Hello Sudhanshu,

    The described behavior is not available out-of-the-box, as the control always try to parse the user input to a valid date and to fill in the missing month and year.

    You can use the following approach to achieve a similar behavior - the textbox value will be cleared and the invalid style will be displayed.

    <%@ Page Language="C#" %>
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     
    <head runat="server">
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
    <title>RadControls</title>
    </head>
    <body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" />
     
    <telerik:RadDatePicker ID="RadDatePicker1" runat="server">
        <ClientEvents OnDateSelected="MyDateSelected" />
    </telerik:RadDatePicker>
     
    <script type="text/javascript">
     
    function MyDateSelected(sender, args)
    {
        var tbValue = args.get_newValue();
        if (tbValue.length <= 2)
        {
            window.setTimeout(function(){
                sender.clear();
                sender.get_dateInput()._invalidate();
                sender.get_dateInput().updateCssClass();
            }, 1);
        }
    }
     
    </script>
     
    </form>
    </body>
    </html>


    Sincerely yours,
    Dimo
    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