SoFunction
Updated on 2025-02-28

JavaScript example code to compare the sequence of two dates


function checkDate(){

//replace(/\-/g, "\/") is to convert dates into long date format based on verification expressions

 var sDate = new Date(document.getElementById_x("datetimepickerStart").(/\-/g, "\/"));
    var eDate = new Date(document.getElementById_x("datetimepickerEnd").(/\-/g, "\/"));

    if(sDate > eDate)
    {
alert("The end date shall not be less than the start date!");
     return false;
    }
    return true;
}