asp.netvalidationtelerikraddatepicker

Telerik rad date picker show error message when user keys in future date


I have a telerik:RadDatePicker in which i am restricting users from selecting future dates by setting MaxDate of it to today in code behind. This works perfectly fine. but when the user keys in a date which is greater than today it just displays an ! in the date picker as shown below:

enter image description here

Instead I want to show a error message to the user "Future dates are not allowed" How can i achieve this? Below is the existing code:

<telerik:RadDatePicker CssClass="cssDate" ID="fromDate" runat="server" 
 Skin="Vista">
 <DateInput ID="DateInput1" runat="server" LabelCssClass="datePick" Skin="Vista">
  </DateInput>
 <Calendar ShowRowHeaders="false" ID="Calendar1" runat="server" UseRowHeadersAsSelectors="False" UseColumnHeadersAsSelectors="False"
ViewSelectorText="x" Skin="Vista">
</Calendar>
<DatePopupButton CssClass="rcCalPopup"></DatePopupButton>
 </telerik:RadDatePicker>

And the code behind where i set the max date of this:

  fromDate.MaxDate = DateTime.Now;

Solution

  • After days of research and asking grandpa google, He provided me link to telerik official forums where they confirmed that this cannot be done.

    Link to what i want to say.

    The reply says "Actually we have modified the error handling logic a bit as our original implementation did not seem quite intuitive. If garbage input is entered or a date out of range is selected the control will internally set its value to null; the visible input field will not clear its contents but will display them with invalid style until a valid value is entered. However, you will still need to handle possible parsing errors in the client-side OnError event handler of the input component (you can find another example here) as if the input does not contain a valid date it will post empty value to the server and this functionality cannot be turned off."

    Hope this piece of information will be helpful to others on SO :).