You can try it out like this:
var A1 = this.getField("installation date").valueAsString;
if (A1.length !=="") {
var userDefinedDate = util.scand("yyyy,m,dd", A1);
var specifiedDate = "2017,5,19"
var QualificationDate = util.scand("yyyy,m,dd", specifiedDate)
if ( userDefinedDate.getTime() <= QualificationDate.getTime() ) {event.value = "Too early for qualification";}
if ( userDefinedDate.getTime() > QualificationDate.getTime() ) {event.value = "Qualified";}
}
if (A1 =="") event.value ="";
You need to use the scand method first in order to convert the date string value to an date object. This, of course, can be achieved in many ways using JavaScript date arithmetic. But in my example above I preferred to parse the date arithmetic by converting the defined date string ("2017,5,19") to an date object and compare the difference between two date objects in milliseconds. In my personal opinion, and as I continue to learn JavaScript scripting, this method provides a very accurate results (but I am sure there are other ways too).
This is referenced in greater detail in the Adobe Acrobat DC SDK, Using JavaScript in Forms,
Developing Acrobat® Applications Using JavaScript™, "Date arithmetic", Page 94
Specifically in the following section:
- " Date arithmetic
It is often useful to do arithmetic on dates to determine things like the time interval between two dates or what the date will be several days or weeks in the future. The JavaScript Date object provides several ways to do this. The simplest and possibly most easily understood method is by manipulating dates in terms of their numeric representation. Internally, JavaScript dates are stored as the number of milliseconds (one thousand milliseconds is one whole second) since a fixed date and time. This number can be retrieved through the valueOf method of the Date object. The Date constructor allows the construction of a new date from this number."