I need to check whether given string is date or not. Note: Without using any library
I try to use this
if (!isNaN(str) || isNaN(Date.parse(str))) {
console.log("Not a Date");
} else {
console.log('It is Date');
}
It works in all scenarios except one, if the given input is Hello 2
, it returns It is Date
So, is there any way with which I can appropriately validate my string against Date?