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

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

1 Answer 144 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Sudhanshu
Top achievements
Rank 1
Sudhanshu asked on 27 Sep 2010, 09:59 AM
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

1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 28 Sep 2010, 02:44 PM
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
Tags
Calendar
Asked by
Sudhanshu
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or