Click here and follow my SAP UI5/FIORI snippets and information Page
<DatePicker id="Date_iD" visible="true" displayFormat="dd MMM yyyy" valueFormat="dd.MM.yyyy" change="Day_select"/>
I have done below "DATE VALIDATION",here you can't selected the future's date and past's date.you can select only today's date.Go through it and please let me know in case of any issue/doubt.
Paste below lines in view.
<DatePicker id="Date_iD" visible="true" displayFormat="dd MMM yyyy" valueFormat="dd.MM.yyyy" change="Day_select"/>Paste below lines in controller.
// If you select date then this method will fire.............
Day_select:function()
{
var TodaysDate=new Date();
var MOnTh=TodaysDate.getMonth();
var YEaRs=TodaysDate.getFullYear();
var DAte=TodaysDate.getDate();
var value=this.byId("Date_iD");
var selectDate=value.getDateValue();
var MOnTh1=selectDate.getMonth();
var YEaRs1=selectDate.getFullYear();
var DAte1=selectDate.getDate();
var date=DAte1-DAte;
var month=MOnTh1-MOnTh;
var year=YEaRs1-YEaRs;
var total=date+month*30+year*365;
if(total>0)
{
sap.m.MessageToast.show("Date can't be in future");
sap.m.MessageToast.show("Date can't be in future");
value.setDateValue(TodaysDate);
return;
}
if(total<0)
{
{
sap.m.MessageToast.show("Date can't be in Past");
value.setDateValue(TodaysDate);
return;
return;
}
}
No comments:
Post a Comment