I want to compare date in java script for validation. This is my code.
There are two text boxes to enter date. one is start date and the other one is end date. When user enter end date which is grater than start date I want to give error message. But I'll get error message when end date is current date. Where I goes wrong?
Ex: Start Date :2009-11-30
End Date: 2009-12-01
if the current date is 2009-12-02. I have got error message.
Code:
var currentDate = new Date()
var day = currentDate.getDate()
var month = currentDate.getMonth()
var year = currentDate.getFullYear()
var today = (year + "-" + month + "-" + day);
...
else if (ED > today){
err= 'End Date cannot be grater than the current date!';
Ex: Start Date :2009-11-30
End Date: 2009-12-01
if the current date is 2009-12-02. I have got error message.
Comment