lundi 2 mars 2020

Multiple conditions in if statement in typescript

I am learning date handling and I have a object with start and end date. Ex: Startdate = "2019-12-05" and Enddate = "2020-05-20"

What I want to do is to create a condition that checks if the dates are not empty, and then that the startdate would either be the same as the existing date or a new date that is not less than today's date.

if ((startDate != null && endDate != null) && (????????????????)) {
    alert('Incorrect date');
     this.dateNotValid = false;
}

In place of the ??????? in the code, I want a logic that forces the startdate to be either "2019-12-05" or today's date "2020-03-02" and upward, any other date should flag alert error.

Aucun commentaire:

Enregistrer un commentaire