谁帮我用javascript写个这样的小程序

来源:百度知道 编辑:UC知道 时间:2024/05/15 17:53:18
要求输入一个年份,判断是不是润年。判断润年的条件:1、能被4整除,但不能被100整除2、能被400整除

function isLeapYear(year)
{
return (year%4==0&&year%100!=0||year%400==0);
}

<html>

<head>

<title>闰年计算</title>
<script language="javascript" type="text/javascript">
function getAnswer()
{
var year = document.getElementById("year").value;
if (year == null || year == "" || year == "undefined"){
alert("Please input year! like this:2009")
} else{
if (year.length != 4){
alert("Input length must be 4!");
} else{
alert(parseInt(year));
if ((parseInt(year) % 4 ==0 && parseInt(year) % 100 != 0) || (parseInt(year) % 400 == 0)){
alert("闰年"); } else{
alert("非闰年");
}
}
}
}
</script>
</head>

<body