javascript - how to compare a user entered date to the current date and change a fields background color? -


i new javascript , working on fallible pdf form , trying set multiple things. first need compare user entered date current date see if withing 5 years day. second thing need change fields background color if date @ 5 year time or outside of range. code have been trying hasn't worked far. there 37 fields need checked this.

for(i=1;i<38;i++){  var y = d.getfullyear();  var d = new date(); var m = d.getmonth();   var d = new date(); var d = d.getday(); //n =2  var strdate = this.getfield("text"+[i]).value; var arrdate = strdate.split('/');  var month = arrdate[0]; var day = arrdate[1]; var year = arrdate[2];  if(year+5>=y){ if(m<=month){ if(d<=day){ this.getfield("text[i]").fillcolor=color.red; }}}} 

i have updated this, working now, can try ?

for(i=1;i<38;i++)  {    var todaydate = new date();    var strdate = "12/25/2009";    var arrdate = strdate.split('/');        var month = arrdate[0];    var day = arrdate[1];    var year = parseint(arrdate[2]) + 5;        var userentereddate = new date(year, month, day);        if(userentereddate <= todaydate)    {      //color change code here...    }      }