|
日期检查的javascript代码 |
|
function isDate(day,month,year) {
// let's first check the user entered numbers if (isNaN(Date.parse(month+"/"+day+"/"+year))) { return false; } var dd = parseInt(day,10); // beware !! the computer handles monthes from 0 to 11. var mm = parseInt(month,10)-1; var yy = parseInt('20'+year,10); var date = new Date(yy,mm,dd); //let's now compare the user's entry with what the computer understand of it if (dd!=date.getDate() || mm!=date.getMonth() || yy!=date.getFullYear()) { return false; } return true; } |