I am trying to verify a date input with a try catch in java script, but the following code doesn't work as I expect it. I expect that the error when the entered date is not date, the catch should execute but here is what I get. see no new date and nothing displayed of what i expect.
console.log("min date :")
try{
minDate = new Date(elminDate.value)
}
catch(e){
console.log("error::")
console.log(err.name)
console.log("changed min")
minDate = new Date()
}
console.log(minDate)
console.log("max date :" )
try{
maxDate = new Date(elmaxDate.value)
}
catch(err){
console.log("error::")
console.log(err.name)
console.log("changed max")
maxDate = new Date()
}
console.log(maxDate)
response :
[Log] min date : (home.html, line 93)
[Log] Tue Aug 01 2017 02:00:00 GMT+0200 (CEST) (home.html, line 103)
[Log] max date : (home.html, line 105)
[Log] Invalid Date (home.html, line 115)