展开全部
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript">
function leapyear()
{
var year=document.getElementById("year").value;
if(!/^\d{4}$/.test(year)) alert("您输入的时间有误");
else if(year%4!=0) alert("不是闰年");
else alert("是闰年");
}
window.onload=function()
{
document.getElementById("button").onclick=leapyear;
}
</script>
</head>
<body>
请输入一个四位数的年份:<input type="text" value="" id="year"/>
<input type="button" value="闰年判断" id="button"/>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript">
function leapyear()
{
var year=document.getElementById("year").value;
if(!/^\d{4}$/.test(year)) alert("您输入的时间有误");
else if(year%4!=0) alert("不是闰年");
else alert("是闰年");
}
window.onload=function()
{
document.getElementById("button").onclick=leapyear;
}
</script>
</head>
<body>
请输入一个四位数的年份:<input type="text" value="" id="year"/>
<input type="button" value="闰年判断" id="button"/>
</body>
</html>
展开全部
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Js计算闰年</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
.style1 {
color: #FF0000;
font-size: 9pt;
}
-->
</style>
</head>
<body>
<script language="javascript">
function leapyear()
{
var now = new Date();
var years = now.getFullYear(document.form1.textfield.value);
var str;
var years = document.form1.textfield.value;
var result =(years%4==0 && years%100!=0)||(years%400==0)?years+"是闰年":years+"不是闰年";
document.form1.textfield2.value = result;
}
</script>
<form name="form1" method="post" action="">
<table width="392" height="64" border="1" align="center" cellpadding="3" cellspacing="2" bordercolor="#9999FF">
<tr>
<td width="152" height="30"><span class="style1">请输入一个四位数的年份:</span></td>
<td width="216"><table width="196" height="29" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="136"><input name="textfield" type="text" value="2007" size="20">
</td>
<td width="60">
<input type="button" name="Button" value="计算" onClick="leapyear();"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2">
<input name="textfield2" type="text" value="" size="51"> </td>
</tr>
</table>
</form>
</body>
</html>
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Js计算闰年</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
.style1 {
color: #FF0000;
font-size: 9pt;
}
-->
</style>
</head>
<body>
<script language="javascript">
function leapyear()
{
var now = new Date();
var years = now.getFullYear(document.form1.textfield.value);
var str;
var years = document.form1.textfield.value;
var result =(years%4==0 && years%100!=0)||(years%400==0)?years+"是闰年":years+"不是闰年";
document.form1.textfield2.value = result;
}
</script>
<form name="form1" method="post" action="">
<table width="392" height="64" border="1" align="center" cellpadding="3" cellspacing="2" bordercolor="#9999FF">
<tr>
<td width="152" height="30"><span class="style1">请输入一个四位数的年份:</span></td>
<td width="216"><table width="196" height="29" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="136"><input name="textfield" type="text" value="2007" size="20">
</td>
<td width="60">
<input type="button" name="Button" value="计算" onClick="leapyear();"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2">
<input name="textfield2" type="text" value="" size="51"> </td>
</tr>
</table>
</form>
</body>
</html>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询