Skip to content

Instantly share code, notes, and snippets.

@igorhasse
Created August 28, 2017 21:13
Show Gist options
  • Save igorhasse/c83bd46ca46cdad8d275bc2a06adbf5d to your computer and use it in GitHub Desktop.
Save igorhasse/c83bd46ca46cdad8d275bc2a06adbf5d to your computer and use it in GitHub Desktop.
Validation Valid Date
// Expect input as d/m/y
function isValidDate(s) {
var bits = s.split('/');
var d = new Date(bits[2], bits[1] - 1, bits[0]);
return d && (d.getMonth() + 1) == bits[1];
}
['0/10/2017','29/2/2016'].forEach(function(s) {
console.log(s + ' : ' + isValidDate(s))
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment