jscript
function compare(txtFrom,txtTo)
{
var a = txtFrom;
var b = txtTo;
var x=a.split('/');
var y=b.split('/');
var oneday=1000*60*60*24;
var dateto=new Date(x[1]-1,x[2],x[0]);
var datefrom=new Date(y[1]-1,y[2],y[0]);
var month1=x[1]-1;
var month2=y[1]-1;
var diff=Math.ceil((datefrom.getTime()-dateto.getTime())/(oneday));
if(diff>=0)
{
alert(diff);
alert("true");
return true;
}
else
{
alert(diff);
alert("false");
alert('in any of the field u have insert wrong:to date>from date');
return false;
}
}
above code is done on javascript for chacking of date
requirement is from date must be less than todate ex-from 03/12/2008 to 03/20/2008 this is correct date and code work properly but if i do like from 03/18/2007 to 03/02/2008 this is correct date but this code is not working.pls guide me
This post has been edited by PsychoCoder: 20 Mar, 2008 - 09:36 PM