I agree with @KooiInc, but not enough to check for NaN
function isGoodDate(dt){ var dts = dt.split('/').reverse() ,dateTest = new Date(dts.join('/')); return !isNaN(dateTest) && dateTest.getFullYear()===parseInt(dts[0],10) && dateTest.getMonth()===(parseInt(dts[1],10)-1) && dateTest.getDate()===parseInt(dts[2],10) }
which will handle the 29/2/2001 and 31/4/2011
For this script to handle US dates run
function isGoodDate(dt){ var dts = dt.split('/') ,dateTest = new Date(dt); return !isNaN(dateTest) && dateTest.getFullYear()===parseInt(dts[2],10) && dateTest.getMonth()===(parseInt(dts[0],10)-1) && dateTest.getDate()===parseInt(dts[1],10) }
source share