Create JS dateobjects and use the getTime() method to compare them. The
function uses US dateformat (mm/dd/yyyy)

function InRange(mydate){
var aDate = mydate.split("/");
var currDate = new Date();
var minDate = new
Date(currDate.getYear(),currDate.getMonth()-2,currDate.getDate());
var maxDate = new
Date(currDate.getYear(),currDate.getMonth()+2,currDate.getDate());
if(aDate.length!=3){
  alert("No date");
  return false;
}
var theDate = new Date(aDate[2],aDate[0]-1,aDate[1]);
if(theDate.getTime=="NaN"){
  alert("No date");
  return false;
}
if (theDate.getTime()>maxDate.getTime() ||
theDate.getTime()<minDate.getTime()){
  alert("date out of range");
  return false;
}
alert("date in range");
return true;
}

Pascal
-----Original Message-----
From: Dave Sueltenfuss [mailto:[EMAIL PROTECTED]
Sent: maandag 29 september 2003 16:20
To: CF-Talk
Subject: OT:Date Comparison using _javascript_


Sorry for the Off Topic post, but I am hoping someone on the list will
be able to help me out.
Does anyone have a script for comparing two dates within _javascript_? I
have a date input field, and the date needs to be within two months
either way of today. Any help is appreciated.

Thanks

Dave Sueltenfuss
Application Developer
Certified ColdFusion MX Developer
Arch Wireless
Phone: 508-870-6711
Fax: 508-836-2760
Email: [EMAIL PROTECTED]


  _____  


[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to