This is a migrated thread and some comments may be shown as answers.

"Date is out of range" - disable alert

8 Answers 353 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Danielle Mascher
Top achievements
Rank 1
Danielle Mascher asked on 25 Nov 2009, 01:51 PM
HI there.

Is there any way that I can disable the alert that appears when navigation to a date using the top navigation arrows that is before the mindate value that I have set?

Your help would be greatly appreciated!!

Danielle

8 Answers, 1 is accepted

Sort by
0
Schlurk
Top achievements
Rank 2
answered on 25 Nov 2009, 02:41 PM
You could subscribe to the OnError event and then use the following piece of javascript:

<script type="text/javascript">  
    function OnError(sender, args)   
    {  
        if (args.get_reason() == Telerik.Web.UI.InputErrorReason.OutOfRange)   
        {  
            args.set_cancel(true); 
        }  
        event.cancelBubble = true;   
    }  
</script>  

That should take care of it.
0
Sachidananda
Top achievements
Rank 1
answered on 23 Aug 2011, 04:51 PM
I am also facing the same problem,can you please let me know where we have to use this code.I add this piece of code to the web page which has the calender control but still it shows the error.
0
Shinu
Top achievements
Rank 2
answered on 24 Aug 2011, 05:55 AM
Hello Sachidananda,

You can attach the event as shown below.
aspx:
<telerik:RadDateInput ID="RadDateInput1" runat="server">
   <ClientEvents OnError="OnError" />
</telerik:RadDateInput>

Thanks,
Shinu.
0
Sachidananda
Top achievements
Rank 1
answered on 24 Aug 2011, 11:47 AM
The problem is with radDatepicker. The date is out of range error is shown when user clicks on the calender icon.because datepicker.calender.rangemindate is set to 14 days in advance and which falls next month.

So in raddatePicker how do we suppress the date is out of range alert for the calender.

Please reply at the earliest as it is very urgent and I am using original version of telerik controls for 2011.
0
Vasil
Telerik team
answered on 29 Aug 2011, 09:28 AM
Hi Sachidananda,

You could set default selected value to be valid in order to avoid "out of range value error" when the selected value it is still not changed.
<telerik:RadDatePicker ID="RadDatePicker1" runat="server" SelectedDate="10/10/2011">
  <Calendar RangeMinDate="10/10/2011">
  </Calendar>
</telerik:RadDatePicker>

Another approach will be to override navigateToDate function of the RadCalendar such a way to check if the date was actually selected or not:
  Telerik.Web.UI.RadCalendar.prototype.navigateToDate = function (date)
  {
 
    if (($find("<%=RadDatePicker1.ClientID%>").get_selectedDate() != null) && !this.RangeValidation.IsDateValid(date))
    {
      date = this._getBoundaryDate(date);
      if (date == null)
      {
        if (this._getFastNavigation().DateIsOutOfRangeMessage != null && this._getFastNavigation().DateIsOutOfRangeMessage != " ")
        {
          alert(this._getFastNavigation().DateIsOutOfRangeMessage);
        }
        return;
      }
    }
    var step = this._getStepFromDate(date);
    this._navigate(step);
  }
 
</script>
<div>
  <telerik:RadDatePicker ID="RadDatePicker1" runat="server">
    <Calendar RangeMinDate="10/10/2011">
    </Calendar>
  </telerik:RadDatePicker>

Best wishes,
Vasil
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Arno
Top achievements
Rank 2
answered on 22 Apr 2013, 10:32 AM
Hi,

I still get this error with version 2012.3.1308.40. It's a very basic scenario: RangeMinDate is set 2 weeks ahead, which is next month. That should be possible without getting errors, right?

Isn't there a way to solve this server side? Or any other work around without javascript?
0
Vasil
Telerik team
answered on 22 Apr 2013, 12:05 PM
Hello Arno,

Change the selected date to be in range, or set SkipMinMaxDateValidationOnServer="true" for your picker.

Greetings,
Vasil
the Telerik team
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.
0
Arno
Top achievements
Rank 2
answered on 22 Apr 2013, 12:56 PM
Thanks for that quick reply Vasil. I now see what I did wrong.

I used to set Calendar.RangeMinDate, .Calendar.RangeMaxDate and .Calendar.SelectedDate of the DatePicker, which does not work if the selected date is in the next month. I now set .MinDate, .MaxDate and .SelectedDate and that works fine.
Tags
Calendar
Asked by
Danielle Mascher
Top achievements
Rank 1
Answers by
Schlurk
Top achievements
Rank 2
Sachidananda
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Vasil
Telerik team
Arno
Top achievements
Rank 2
Share this question
or