Created
December 30, 2009 20:53
-
-
Save johnhmj/266380 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script language="javascript" type="text/javascript"> | |
<!-- | |
// 函式 | |
function check(year, month, date) | |
{ | |
// 宣告 Date 物件 | |
var today = new Date(); | |
// 用年月日判斷 | |
if ( year > today.getFullYear() ) | |
{ | |
document.write("Incorrect Year."); | |
return; | |
} | |
if ( month > today.getMonth() ) | |
{ | |
document.write("Incorrect Month."); | |
return; | |
} | |
if ( date > today.getDate() ) | |
{ | |
document.write("Incorrect Date."); | |
return; | |
} | |
// 顯示 | |
document.write("Your birthday might be correct.<br>"); | |
document.write("You're " + (today.getFullYear() - year) + " year-old.\n"); | |
} | |
// 呼叫(執行)函式 | |
// 假定日期 2000年 10月 10日 | |
check( 2000, 10, 10); | |
//--> | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment