Validating date in JavaScript

Blog / JavaScript ·

A very simple way to validate date in JavaScript.

function (mm, dd, yyyy) {
    var d = new Date(mm + "/" + dd + "/" + yyyy);
    return d.getMonth() + 1 == mm && d.getDate() == dd && d.getFullYear() == yyyy;
  }

Krasimir Tsonev With over two decades of deep programming expertise, I offer comprehensive web consultancy and stack audits, alongside specialized workshops, training, and engaging public speaking to elevate your team's skills and optimize your digital presence. Contact me.

Keywords: date mm dd yyyy
Share the post on Twitter, Facebook, LinkedIn