So I got my code to work just fine in Chrome. In FF I get the first two alerts with the dates and they’re formatted properly and everything but if a past date is chosen it doesn’t throw the third alert. In IE I get all three alerts but even if I choose a future date. As I mentioned Chrome works as it should so if anyone can provide some insight into making it work across them all that’d be great.
function check()
{
var selecteddate = document.form1.selectmonth.value + "-" + document.form1.selectday.value + "-" + document.form1.selectyear.value;
var d = new Date();
var today = (d.getMonth()+1) + "-" + d.getDate() + "-" + d.getFullYear();
// I'd then make some alerts and it'd return the selected date and today with no problem
alert(selecteddate);
alert(today)
//Now for the if statement is where it just stops working. I think maybe I'm doing
//something wrong just solely in the if statement.
if(new Date(selecteddate) < new Date(today))
{
alert("Past dates are not valid");
return false;
}
}
</script>
your dates are invalid to FF, use
"/"in place of the"-"forselecteddateandtoday.or what about just using
instead of