DateTimePicker icon indicating copy to clipboard operation
DateTimePicker copied to clipboard

Need validation for past date selection. If we select the past date, it should show an alert and the date picker should not be closed

Open lalitha123 opened this issue 8 years ago • 1 comments

Hi,

I have added validation for past time setting in date picker. But after showing error message in alert, the date picker is closing. Can we prevent the closing of date picker and keep it opened if error displayed. I am validating the date time when clicked on "Done" button. My code is as follows.

formatDateTimeString: function(oDate, sMode,oInputElement)
{   
    var newdateval=oDate.yyyy+"-"+oDate.MM+"-"+oDate.dd+" "+oDate.HH+":"+oDate.mm+":"+oDate.ss;                          
    var dt1=new Date(newdateval); 
    var dt2=new Date('<?php echo date('Y-m-d H:i:s'); ?>');
    var diffhrs =(dt1 - dt2) /(3600*1000); 
    if(diffhrs < 0)
    {
       // Past date time selection (Wrong case) 
       alert("Please select future time for your appointment");
    }
    else
    { 
        // Future date time selection (Success case)
    }       
    return oDate.day + ", " + oDate.dd + " " + oDate.month;  
}

Please help me regarding this.

lalitha123 avatar May 20 '16 06:05 lalitha123

Currently, there is no provision to achieve this. We will add this feature.

When you use formatDateTimeString callback function, you should also write parseDateTimeString callback function to parse the date specified. If you have not added it already, that may cause an error.

nehakadam avatar May 24 '16 17:05 nehakadam