I have two date fields: FROM
and TO
. I am trying to pass the date to JavaScript so that I can compare the dates and month of the two dates entered.
I am getting the date using
var date= document.getElementById("fromdate").value;
Here I am getting the date from an element in the form of yyyy-mm-dd
. Now I am trying to extract the date, month and year individually for some comparison.
I am using var month=date.getMonth();
but it's not working.