这个代码没什么,贴上来,我想表达的重点隐藏在代码中,找找看! 复制代码 代码如下: show date <BR>name="mark"; <BR>function showLastDate() <BR>{ <BR>alert(name); <BR>var reg=/^\d{4}\/\d{1,2}\/\d{1,2}$/; <BR>var inputdate=$("#indate").val(); <BR>if(!reg.test(inputdate)) <BR>{ <BR>alert("please input date like:2013/1/14"); <BR>return; <BR>} <BR>var month=parseInt(inputdate.split("/")[1]); <BR>if(month>12||month==0) <BR>{ <BR>alert("please input month range from 1-12"); <BR>return; <BR>} <BR>var showdate=getLastDate(inputdate); <BR>$("#lastdate").val(showdate); <BR>} <BR>function getLastDate(indate) <BR>{ <BR>alert(name); <BR>var year=parseInt(indate.split("/")[0]); <BR>var month=parseInt(indate.split("/")[1]); <BR>//run nian <BR>var isrun=false; <BR>if((year%4==0 && year%100!=0)|| year%400==0) <BR>isrun=true; <BR>switch(month) <BR>{ <BR>case 2: <BR>if(isrun) <BR>{return 29;} <BR>else <BR>{return 28;} <BR>case 1: <BR>case 3: <BR>case 5: <BR>case 7: <BR>case 8: <BR>case 10: <BR>case 12: <BR>return 31; <BR>default: <BR>return 30; <BR>} <BR>} <BR> input date:example:2013/1/14 input date: