Reset RadDateTimePicker DateInput validation formatting

3 posts, 0 answers
  1. William
    William avatar
    4 posts
    Member since:
    May 2013

    Posted 30 May 2013 Link to this post

    I am having an issue in clearing the contents of the DateInput box of a RadDateTimePicker via client-side javascript when invalid data has been entered.

    In my scenario, I have two radio buttons (asp:RadioButton) that allow a user to select to either perform an action immediately or schedule the action for a future date/time.  The later radio button is coupled with a RadDateTimePicker.  If the user initially enters a date then switches to perform the action immediately, the RadDateTimePicker should be cleared.

    If a valid date has been selected or entered, I am able to clear the contents with:

    var dtTmPicker = $find("<%= SchedStartTime.ClientID %>");

    However, if an invalid value has been entered for the date, the call to .clear() has no effect (because the underlying date value has not been set when the visible value is not valid).

    Based on a few scattered forum posts, I have attempted to reset the invalid value, warning icon, and formatting on the field with:

    var dtTmPicker = $find("<%= SchedStartTime.ClientID %>");
    dtTmPicker.get_dateInput()._invalid =

    This clears the text, but the warning icon and formatting remain.

    Interestingly, I can set ._invalid=true and call .updateCssClass() to turn the validation icon/formattting on; and again set it to false to clear the validation icon/formatting.  But I can only do this when NO invalid value has been entered in the control.  Once an invalid value has been entered, I can only clear the text but not the icon/formatting.

    Is there something else that needs to be done to clear the form and reset the validation?  Any help is greatly appreciated.

  2. Vasil
    Vasil avatar
    1604 posts

    Posted 04 Jun 2013 Link to this post

    Hello William,

    Yes when the input holds invalid value, the .get_value() returns "". So clear("") does not do anything, since the input is already empty.

    You can use the following approach to workaround this:

    var dateInput = $find("<%= SchedStartTime.ClientID %>").get_dateInput();

    Also from this release, you will be able to use client side set_invalid(false) method.

    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. William
    William avatar
    4 posts
    Member since:
    May 2013

    Posted 04 Jun 2013 Link to this post

    Thank you for the reply, Vasil.  That works well.

    As a workaround, I had figured out I could just set the field to a valid value immediately prior to clearing as follows:

    var dtTmPicker = $find("<%= SchedStartTime.ClientID %>");
    tmpDate = new Date();

    I prefer your method.  Thanks again.
Back to Top