Apex 23.1
please help to Comparing Dates using JavaScript. I have below DA which works fine after on 2nd or 3rd attemp, what's wrong here with it? if I select a Date from previous Month which DD is less or equals to From Date it is showing alert but from previous Month am select Date which DD is greater than From DD it is not showing alert…
please help what I am doing wrong here? what is the best and recommended way to done this?
note: i used alert and apex.message.showErrors both due to its required. mentioned DD above is DD in MON/DD/YYYY
const date1 = new Date(apex.item("P549_FROM_DATE").getValue());
const date2 = new Date(apex.item("P549_TO_DATE").getValue());
if (date2.getTime() < date1.getTime()) {
alert('End Date must be greater or equal to Start Date');
apex.message.showErrors([
{
type: "error",
location: ["inline" ],
pageItem: "P549_TO_DATE",
message: "End Date must be greater or equal to Start Date"
}
]);
}
regards