I have a RadDatePicker in which I load SpecialDays with many RadCalendarDay objects. I set the IsSelectable property of many of these to false. When the calendar dropdown is displayed, all dates are properly enabled or disabled.
But in the DateInput the user can still enter and submit one of the dates where IsSelectable=false.
I see all of the dates are in the client. Is there any client-side script that can be used against that data to prevent submission of an invalid date?
If we need to validate on the server, I'm not certain of what the logic should look like. The following code detects the condition but I'm not sure if this is the right way to go about it:
protected void RadDatePicker1_SelectedDateChanged( object sender , Telerik.Web.UI.Calendar.SelectedDateChangedEventArgs e ) |
{ |
RadDatePicker picker = sender as RadDatePicker; |
if ( e.NewDate == null ) |
return; |
RadCalendarDay day = picker.Calendar.SpecialDays[ e.NewDate ]; |
if ( day.IsSelectable == false || day.IsDisabled == true ) |
{ |
// set picker to invalid state. |
// display invalid selection message. |
// stop other processing. |
return; |
} |
// date is valid, OK to continue processing |
} |
How would we invalidate date picker from the server like that, register a script and force the client to do it?
Thanks.