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

RadDatePicker fails after displaying validation message

3 Answers 131 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Kalyan
Top achievements
Rank 1
Kalyan asked on 17 Nov 2008, 10:05 PM
Here are the steps to repro
* Place two RadDatePickers (start date & end date) on a page
* Add javascript validation logic for OnPopupClosing for both controls
* If end date is before start date show validation message, similarly if start date is after end date display message
* Most of the scenarios it works as expected. However it breaks in this scenario

- When you get validation message on end date being before start date, move calendar to previous month & then back to current month. Now try to enter validate date for end date field, it still display validation message.

Let me know if you are able to repro this bug.

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 18 Nov 2008, 08:06 AM
Hi Kalyan,

Please try the below JavaScript for RadDatePicker PopupClosing.

JavaScript:
function PopupClosing(sender, args) 
{      
        // process the event only for the second datepicker 
        if (sender.get_id() == "<%= RadDatePicker1.ClientID %>"
            return
             
        // process the event only if the first datepicker is not empty 
        var firstDatePicker = $find("<%= RadDatePicker1.ClientID %>");   
        var secondDatePicker = $find("<%= RadDatePicker2.ClientID %>"); 
        var dateArr = secondDatePicker.get_calendar().get_selectedDates(); 
        if(dateArr[((dateArr.length)-1)]) 
        { 
            var date = new Date(dateArr[((dateArr.length)-1)][0], dateArr[((dateArr.length)-1)][1] - 1, dateArr[((dateArr.length)-1)][2]); 
            var dateToCompare = firstDatePicker.get_selectedDate(); 
            if(date < dateToCompare) 
            { 
                alert("Please, choose a date later than the Start Date!"); 
                args.set_cancel(true);                         
            } 
        } 


Thanks,
Shinu.
0
Kalyan
Top achievements
Rank 1
answered on 19 Nov 2008, 05:16 PM

Shinu thanks for the reply. However the problem still remains, as I stated in my earlier note RadDatePicker works fine in most of the scenarios except the one.

Let me explain again in detail.

We have two raddatepicker as you mentioned in your sample firstdtpicker & seconddtpickter.

In seconddtpicker select date(10/25/2008) which is before firstdtpicker date(11/3/2008). You will notice alert msg, which is good. Now select (11/15/2008) as date for seconddtpicker, you will still get alert msg which you shouldn't as this is valid date.

My guess is RadDatePicker is not clearing its validation flag unless calendar is closed, which is not correct. We should let user select correct date without closing calendar.

0
Mohammed Ahmed
Top achievements
Rank 1
answered on 28 Jan 2009, 06:48 PM
I got the solution for you just add one line and will take care of it.

 

if(dateArr.length!=0) // here check the length before continuing with other logic.

 

 

if(dateArr[((dateArr.length)-1)])

 

Tags
Calendar
Asked by
Kalyan
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Kalyan
Top achievements
Rank 1
Mohammed Ahmed
Top achievements
Rank 1
Share this question
or