"Date is out of range" - disable alert

9 posts, 0 answers
  1. Danielle Mascher
    Danielle Mascher avatar
    5 posts
    Member since:
    Nov 2009

    Posted 25 Nov 2009 Link to this post

    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
  2. Schlurk
    Schlurk avatar
    812 posts
    Member since:
    May 2009

    Posted 25 Nov 2009 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Sachidananda
    Sachidananda avatar
    12 posts
    Member since:
    Jun 2011

    Posted 23 Aug 2011 Link to this post

    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.
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 24 Aug 2011 Link to this post

    Hello Sachidananda,

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

    Thanks,
    Shinu.
  6. Sachidananda
    Sachidananda avatar
    12 posts
    Member since:
    Jun 2011

    Posted 24 Aug 2011 Link to this post

    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.
  7. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 29 Aug 2011 Link to this post

    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 >>

  8. Arno
    Arno avatar
    19 posts
    Member since:
    Sep 2010

    Posted 22 Apr 2013 Link to this post

    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?
  9. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 22 Apr 2013 Link to this post

    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.
  10. Arno
    Arno avatar
    19 posts
    Member since:
    Sep 2010

    Posted 22 Apr 2013 Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017