RadDatePicker:AutoCorrect Override (othe forum posts not working)

10 posts, 1 answers
  1. Chris Lynch
    Chris Lynch avatar
    5 posts
    Member since:
    Mar 2010

    Posted 24 Mar 2010 Link to this post

    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,

  2. Dimo
    Admin
    Dimo avatar
    8333 posts

    Posted 25 Mar 2010 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Chris Lynch
    Chris Lynch avatar
    5 posts
    Member since:
    Mar 2010

    Posted 25 Mar 2010 Link to this post

    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.
  5. Answer
    Dimo
    Admin
    Dimo avatar
    8333 posts

    Posted 30 Mar 2010 Link to this post

    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.
  6. Chris Lynch
    Chris Lynch avatar
    5 posts
    Member since:
    Mar 2010

    Posted 30 Mar 2010 Link to this post

    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.
  7. Dimo
    Admin
    Dimo avatar
    8333 posts

    Posted 30 Mar 2010 Link to this post

    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.
  8. Kazimierz Szadkowski
    Kazimierz Szadkowski avatar
    9 posts
    Member since:
    Sep 2009

    Posted 31 Mar 2010 Link to this post

    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 ;)
  9. Dimo
    Admin
    Dimo avatar
    8333 posts

    Posted 01 Apr 2010 Link to this post

    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.
  10. Bill Witt
    Bill Witt avatar
    3 posts
    Member since:
    Dec 2008

    Posted 12 May 2010 Link to this post

    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
  11. Chris Lynch
    Chris Lynch avatar
    5 posts
    Member since:
    Mar 2010

    Posted 17 Aug 2010 Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017