-3

In the javascript side, I am checking enddatetime >= startdatetime,but it's not working. How to handle it in Javascript side?

<ui:inputDateTime aura:id="startTime" label="Start Time" class="field" value="{!v.startDateTimeVal}" displayDatePicker="true" required="true" />
<ui:inputDateTime aura:id="endTime" label="End Time" class="field" value="{!v.endDateTimeVal}" displayDatePicker="true" required="true" />

Javascript side:

var stardateTime=component.find("startTime").get("v.value");
var enddateTime=component.find("endTime").get("v.value");
if(enddateTime>=stardateTime){
    component.set("v.truthy",true);
    component.set("v.message1", "End date Time cannot be a blank");
    return null;
}

Please check below image: enter image description here

1

You'll want to convert those values to Date values first:

if(new Date(enddateTime) >= new Date(stardateTime)) {
1
  • @AnnappaPH It's working as you wrote it; you might have meant <= instead?
    – sfdcfox
    Jun 15 '18 at 5:55

Not the answer you're looking for? Browse other questions tagged or ask your own question.