I'm quite new to JavaScript and I experiment a lot to get used to it. I trying to write JavaScript function that determinates if the date is from the past or future. It used datepicker form and somehow the if statement isn't working properly because whatever date I select it displays "Date from the future".
function selectDate()
{
var d = new Date();
var day = d.getDate();
var month = (d.getMonth() +1);
var year = d.getFullYear();
var x=document.getElementById("dateSelection");
if (month.length < 2) month = '0' + month;
if (day.length < 2) day = '0' + day;
if (d > x)
{
document.write("Date from the past" + "<br>");
document.write("Today is " +day+ "/" +month+ "/" +year+ "");
}
else (d < x)
{
document.write("Date from the future" + "<br>");
document.write("Today is " +day+ "/" +month+ "/" +year+ "");
}