I have implemented a date validation method in my application to check if a given date is valid or not.
myApp.isValidDate = function(date) {
var timestamp;
timestamp = Date.parse(date);
if (isNaN(timestamp) === false) {
return true;
}
return false;
};
While the method works correctly in most cases, I encountered an issue when entering a value like "something.com Eq Phone 1"
. Despite this input, Date.parse returned 978300000000
and the method still returned true
.
I am puzzled by how it managed to parse this unconventional string as an actual date.