Skip to content

Instantly share code, notes, and snippets.

@johnhmj
Created December 30, 2009 20:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnhmj/266380 to your computer and use it in GitHub Desktop.
Save johnhmj/266380 to your computer and use it in GitHub Desktop.
<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