最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

js根據(jù)給定的日期計(jì)算當(dāng)月有多少天實(shí)現(xiàn)思路及代碼

 更新時(shí)間:2013年02月25日 11:02:13   作者:  
根據(jù)給定的日期計(jì)算當(dāng)月有多少天,想必這樣的功能大家都想實(shí)現(xiàn)吧,所以本文的出現(xiàn)相當(dāng)有必要,接下來(lái)看下實(shí)現(xiàn)代碼,感興趣的朋友可以了解下,希望對(duì)你有所幫助
這個(gè)代碼沒什么,貼上來(lái),我想表達(dá)的重點(diǎn)隱藏在代碼中,找找看!
復(fù)制代碼 代碼如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>show date</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
name="mark";
function showLastDate()
{
alert(name);
var reg=/^\d{4}\/\d{1,2}\/\d{1,2}$/;
var inputdate=$("#indate").val();
if(!reg.test(inputdate))
{
alert("please input date like:2013/1/14");
return;
}
var month=parseInt(inputdate.split("/")[1]);
if(month>12||month==0)
{
alert("please input month range from 1-12");
return;
}
var showdate=getLastDate(inputdate);
$("#lastdate").val(showdate);
}
function getLastDate(indate)
{
alert(name);
var year=parseInt(indate.split("/")[0]);
var month=parseInt(indate.split("/")[1]);
//run nian
var isrun=false;
if((year%4==0 && year%100!=0)|| year%400==0)
isrun=true;
switch(month)
{
case 2:
if(isrun)
{return 29;}
else
{return 28;}
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
return 31;
default:
return 30;
}
}
</script>
</head>
<body style="margin-left:100px;margin-top:20px;">
<br><br>
input date:<input id="indate" type="text" />example:2013/1/14<br><br>
<input type="button" onclick="showLastDate()" value="Get Last Date"/><br><br>
input date:<input id="lastdate" type="text" /><br>
</body>
</html>

相關(guān)文章

最新評(píng)論

宜章县| 布尔津县| 光泽县| 岑巩县| 龙陵县| 达孜县| 长白| 霞浦县| 梅河口市| 陇南市| 邵阳市| 桦南县| 伽师县| 江油市| 临海市| 黎川县| 万山特区| 阳新县| 孝义市| 北票市| 彭泽县| 辽宁省| 广元市| 蓬莱市| 启东市| 栾城县| 泰州市| 普宁市| 灯塔市| 衡阳县| 开原市| 腾冲县| 大邑县| 金塔县| 广南县| 和平县| 汕头市| 密云县| 南昌县| 遂昌县| 灵璧县|