Friday, January 16, 2009

Comparing dates in client-side script


 

You need to convert them to a Date object. You might also need to convert it to IsoDate format.

var myCQAStart = new Date(Form1.tCQAStartDate.value);
    var myCQAStop = new Date(Form1.tCQAStopDate.value);
    var myCQAMin = new Date(IsoDate(Form1.minStartTime.value));
    var myCQAMax = new Date(IsoDate(Form1.maxStopTime.value));

    if (myCQAStart < myCQAMin){

        alert("Start Date comes before than the earliest Start Time.");
        return false;

    }

if (myCQAStop > myCQAMax){

        alert("Stop Date comes after than the latest Stop Time.");
        return false;

    }

No comments:

Post a Comment