I have a entry form in which I can allow today's date and future date but can't allow yesterday and previous days. I need to do this validation using java-script on client side.
var futuredate = new Date($("#Deadline").val());
var today = new Date();
This gives me date with time. Mon Nov 04 2013 00:00:00 GMT+0530 (India Standard Time)
I want only date to compare as when user enters today's date
entered date is : Fri Apr 05 2013 00:00:00 GMT+0530 (India Standard Time)
current date from new Date():Fri Apr 05 2013 16:53:00 GMT+0530 (India Standard Time)
I tried using sethours()
it worked fine for current month, but as it converts date in number it creates problem when date entered is of previous or any before month.
for example: the date entered date is 23/3/2013
and today is 5/4/2013
it considers the entered date as valid.
var futuredate = new Date($("#Deadline").val()).setHours(0, 0, 0, 0);
var today = new Date().setHours(0, 0, 0, 0);
if (futuredate >= today) {
alert("Valid");
}
else if (futuredate < today) {
alert("InValid");
}