Compare date with current date using javascript

I have a from with input field
I want to compare with the current date if it is less than today’s date it should display alert(“wrong date”) if it is today’s date or next date it should alert(“date accepted”)
but I have a issue
ISSUE
while enter today date it showing alert(“wrong date”) rest all works perfect
code is
/ get date from user
var seledatetab = document.getElementById(“selectdateTab”).value;
//get today’s date in string
var todayDate = new Date();

//compare dates
if (Date.parse(seledatetab) < Date.parse(todayDate) ){
	alert ("Enter a valid date");
	return false;
	}
	else {
	alert (" Your booking is registered we will call you within 1 hours ");
	return true;
}

I’d imagine the problem is that when you create the todayDate variable, it also includes the time, so midday today would probably evaluate to later than just today with no time component.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.