function isTime(t) { var r = t.match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/); if (r === null) { return false; } r[1] = parseInt(r[1]); r[3] = parseInt(r[3]); r[4] = parseInt(r[4]); var d = new Date(r[1], r[3] - 1, r[4]); return (d.getFullYear() === r[1] && (d.getMonth() + 1) === r[3] && d.getDate() === r[4]);}console.log(isTime("2014-06-06"));