Avoid default today

2 posts, 0 answers
  1. Arnold
    Arnold avatar
    1 posts
    Member since:
    Dec 2016

    Posted 13 Sep 2017 Link to this post

    I have an issue with the DateTimePicker.
    I'm using this control mainly for keyboard entry.
    I live in The Netherlands and our date format is "dd-mm-yyyy".

    The issue is as follows: 
    If the current month has less than 31 days (like this month september for example), we are not able to enter a date that starts with 31 (like 31-08-2017).
    This happens because as soon as I start typing, todays date appears in the editor. This means the day is validated as a day in the month september.
    We would have to change the month first, than move back to the day portion and correct it. But, as you would admit, this is unnecessary cumbersome.

    Is it possible to not have a default date appear as soon as the user starts typing?
    If not, is it possible to have a default date like 01-01-2017 when the user starts typing?

    Tnx for your help

  2. Hristo
    Hristo avatar
    1520 posts

    Posted 13 Sep 2017 Link to this post

    Hello Arnold,

    Thank you for writing.

    The observed behavior follows the behavior of the standard .NET DateTimePicker control. Typing in the editor also results in changing the selected date in the calendar. In order to achieve your task, I can suggest using the Free From Date Time Parser: http://docs.telerik.com/devtools/winforms/editors/datetimepicker/free-form-date-time-parsing

    Please check my code snippet below: 
    CultureInfo culture = new CultureInfo("nl-NL");
    this.radDateTimePicker1.Culture = culture;
    this.radDateTimePicker1.DateTimePickerElement.Calendar.Culture = culture;
    this.radDateTimePicker1.DateTimePickerElement.TextBoxElement.MaskType = MaskType.FreeFormDateTime;

    I hope this helps. Should you have further questions please do not hesitate to write back.

    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top