I have two text fields in a form. Both accepts dates. I'd like to check whether the second date provided is exactly one year in the future from the first provided date.
There are two issues I have.
1. Make sure that the strings provided are indeed dates (I would use strtodate() in PHP for this)
2. Regardless of month provided, making sure that the second date is exactly a year in the future of the already provided year
I've only captured the values and passed them to Date(). However, it can only handle european style, and if I enter 1981-06-16, the value returned is Jun 15 1981 17:00:00 which is obviously wrong.
Here is the simple broken code I have
var text1 = document.getElementById("text1"); var start_date = new Date(text1.value); var text2 = document.getElementById("text2"); var end_date = new Date(text2.value); alert(start_date);
I need some guidance.