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:
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:
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.
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 %>"
);
dtTmPicker.clear();
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().set_textBoxValue(
""
);
dtTmPicker.get_dateInput()._invalid =
false
;
dtTmPicker.get_dateInput().updateCssClass();
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.