Your syntax is a mess... You need to learn the basics first, then try to do something basic that works.
First of all in your form event you need to call the function inserting the parentesis: <form onsubmit="submit()">
, but apparently "submit" is a reserved word, so you need to use other function name.
This line is completely wrong: var date1=input[type="date"];
This is also wrong, as console.log does not return a value to "date2": var date2=console.log(Date());
and Date() is not what you want. You need a new instance of date: "new Date()"
I made some fixes in the example below. Compare each line with your code and see the syntax differences:
function validateForm() {
var date1 = document.querySelector('#myDate').valueAsDate;
var date2 = new Date();
console.log('date1', date1);
console.log('date2', date2);
var dateDiff = date2 - date1;
console.log('dateDiff ', dateDiff );
alert(dateDiff);
return false;
}
<form onsubmit="return validateForm()">
<input type="date" id="myDate" />
<button type="submit">Submit</button>
</form>