javascript:

function isDate(s) {
if (s.search(/^\d{1,2}[\/|\-|\.|_]\d{1,2}[\/|\-|\.|_]\d{4}/g) != 0)
return false;

s = s.replace(/[\-|\.|_]/g, “/”);

var dt = new Date(Date.parse(s));

var arrDateParts = s.split(“/”);
return (
dt.getMonth() == arrDateParts[0] – 1 &&
dt.getDate() == arrDateParts[1] &&
dt.getFullYear() == arrDateParts[2]
);
}

Advertisements