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

RadDatePicker:AutoCorrect Override (othe forum posts not working)

9 Answers 212 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Chris Lynch
Top achievements
Rank 1
Chris Lynch asked on 24 Mar 2010, 05:42 PM
I have read throught he forum and see that a number of people do not like the feature of the RadDatePicker auto correcting.

To rehash:

If I enter 13/12/2010 I DO NOT want the control to automatically change it to 12/13/2010.

I have tried adding the following:

 

 

<telerik:RadScriptBlock runat="server">  
 
    <script type="text/javascript">  
 
        Telerik.Web.UI.RadDateInput.prototype.parseDate = function(value, baseDate) {  
 
            if (new Date(value) != "NaN")  
 
                return value;  
 
            }   
 
    </script>   
 
</telerik:RadScriptBlock> 
 


However, while this certainly causes the dates to no longer change it also prevents me from putting in VALID dates and prevents me from using the calendar control. I would appreciate any clarification I may be missing.

Thanks,

9 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 25 Mar 2010, 10:26 AM
Hi Chris,

The RadDateInput (used internally by RadDatePicker) always uses a single DateFormat to parse the user input and a single DisplayDateFormat to display the parsed value. By default DisplayDateFormat is the same as the DateFormat. If your users will be entering dates like "dd/mm/yyyy", then it is recommended to set the same DateFormat to prevent autocorrection.

I am afraid it is not possible to force the control to display dates in different formats, depending on what the user has entered.

Greetings,
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.
0
Chris Lynch
Top achievements
Rank 1
answered on 25 Mar 2010, 02:30 PM
Dimo,

Thanks for the reply. I tried what you suggested:

<telerik:RadDatePicker ID="ctlDate" runat="server">  
     <DateInput DateFormat="MM/dd/yyyy" DisplayDateFormat="MM/dd/yyyy"      
     runat="server">                             
     </DateInput> 
</telerik:RadDatePicker> 

And it does not prevent autocorrection.

I think there may be a misunderstanding of what I want. I expect that my users should enter the date as "12/13/2010" for December 13th of 2010. If they accidentely enter an invalid date 13/12/2010 or 343221, whatever, if it is not in the format MM/dd/yyyy I do NOT want the date picker to try to GUESS what the user meant. It should leave it alone and I will validate it later.

The above changes I made still changes inputs when I tab out of the field. This is unacceptable and I need to find out how to change that behavior.

Thanks.
0
Accepted
Dimo
Telerik team
answered on 30 Mar 2010, 01:42 PM
Hi Chris,

What I meant to say is that you should set DateFormat in such a way, so that it matches the month/day order that the end-users will most probably use. I am afraid that the autocorrect functionality has been implemented on purpose and it cannot be prevented, unless you disable the whole parsing mechanism of the embedded DateInput control, which is the same as using a regular textbox.

http://www.telerik.com/community/forums/aspnet-ajax/calendar/raddatepicker-autocorrect.aspx

Regards,
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.
0
Chris Lynch
Top achievements
Rank 1
answered on 30 Mar 2010, 02:14 PM
Thanks for the reply.

I will keep in mind that your product violates multipe user interface best practices so in the future I can be sure to not recommend it to clients.

I will implent this the correct way using jquery and strip this control from my application.
0
Dimo
Telerik team
answered on 30 Mar 2010, 04:30 PM
Chris,

So you don't want the RadDateInput control to guess and autocorrect, right? Suppose that you have set the following DateFormat -

dd/mm/yyyy

and the user enters 05/07/10 in the textbox. If you want to support both mm/dd/yyyy and dd/mm/yyyy formats at the same time, what date should be that?

Can you specify which best practice do we violate in the case that we are discussing?

Another thing - the DateInput control, which is internally used by RadDatePicker, intentionally tries to guess what the user has entered, because of popular demand. The purpose is to support partial dates, e.g. if you enter "july 5", the control will parse the input and assume that you mean "July 5 of the current year". That's why the control always splits the user input into parts, figures out which part is what, then constructs a date object and applies it to the textbox in the specified format.

http://www.telerik.com/help/aspnet-ajax/input_raddateinputparsing.html


Regards,
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.
0
Kazimierz Szadkowski
Top achievements
Rank 1
answered on 31 Mar 2010, 07:50 AM
In my opinion assumptions you described (july 5 thing) are useful and demanded. However, when user enters a date 29/02/2010 datepicker should not automatically correct it to 28/02/2010 (or at least such autocorrection should be optional). Maybe the date user was actually supposed to insert was 29/02/2012, which would be correct? With autocorrection user cannot realize there is a mistake. Another example: user inserts 31/04/2010, date picker automatically changes it to 30/04/2010. But user should have inserted 31/05/2010 - if incorrect date was simply validated, big red message or border would force user to reconsider. Now, he is doomed ;)
0
Dimo
Telerik team
answered on 01 Apr 2010, 10:19 AM
Hello Kazimierz,

The described behavior can be observed if you enter a day number larger than 31 - in this case the user input remains unchanged and is displayed in red color. We may consider adding the requested functionality in the future.

All the best,
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.
0
Bill Witt
Top achievements
Rank 1
answered on 12 May 2010, 02:01 PM
Hi Chris,

I had a similar issue and fixed it by implementing a custom javascript datetime parser.  Check out this post
Custom Javascript datetime parser  which has a full working example and can be modified to handle any format.

Bill
0
Chris Lynch
Top achievements
Rank 1
answered on 17 Aug 2010, 03:00 PM
Thanks for understanding the issue Bill. I will check it out in case I run into this again.
I solved my problem by stripping out telerik controls and using jquery.
Tags
Calendar
Asked by
Chris Lynch
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Chris Lynch
Top achievements
Rank 1
Kazimierz Szadkowski
Top achievements
Rank 1
Bill Witt
Top achievements
Rank 1
Share this question
or