I am in new in javascript. i am having two dates date1 and date2 .when date1 is selecting from the user date2 is current date.when date1 is greater than date2 means its shows error like Date1 should be less than Current date.it shows Correctly.But i am selecting less than current date it shows same error.only it allows current date,I need help from you for comparing dates
this is my Script
var today=new Date();
var monthtext=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sept','Oct','Nov','Dec'];
var DateFormat = today.getDate();
if (DateFormat < 10)
{
var now ="0"+ today.getDate() + "/" + monthtext[today.getMonth()] + "/" + today.getYear();
}
else
{
var now = today.getDate() + "/" + monthtext[today.getMonth()] + "/" + today.getYear();
}
//alert(now)
if(dateChoosed > now)
{
alert('Date Should be less than Current Date')
}
else
{
valueFld[0].value = dateChoosed;
}
}
in above datechoosed is came from the front end aspx page.