<div class="codetitle"> <span><a style="CURSOR: pointer" data="54784" class="copybut" id="copybut54784" onclick="doCopy('code54784')"><u>複製程式碼</u></a></span> 程式碼如下:</div> <div class="codebody" id="code54784"> <br><script language="java"> { <BR> var r = str.match(/^(d{1,4})(-|/)(d{1,2})2({1,2)$/1; 🎜> if(r==null)return false; <BR> 🎜> if (d.getFullYear()= =r[1]&&(d.getMonth() 1)==r[3]&&d.getDate()==r[4]) <BR> { <🠜> ().getFullYear() ; <BR> return("年齡 = " (Y-r[1]) " return("輸入的日期格式錯誤!"); <BR> } <BR> alert(ages ("1980-03-22")); <BR> alert(ages("2002-01-31")); <BR> alert(ages("2002-01-41")); <BR> script><BR><BR></script> </div>