How to calculate leap year in JavaScript - ASP TANMOY

Latest

Tuesday, 22 April 2014

How to calculate leap year in JavaScript



Description:

Today I will explain a simple calculation to check leap year. This calculation I have use in javaScript so that we can easily create a program to check a leap year. It is a very simple calculation. You can copy this code to your editor and run the project. 


Code:

<html>
<head>
<title>Calculate simple interest</title>
<script language="javascript">
function year(f)
{
var a1=parseInt(document.f.no.value);
var a2;
a2=(a1%4);
if(a2=="0")
alert("The year "+a1+" is leep year");
if(a2!=0)
alert("The year "+a1+" is  not leep year");
}
</script>
</head>

<body>
<hr>
<h1><center>Program to find leep year in java script</center></h1>
<hr>
<form name="f" onSubmit="year(this)">
<center>
<p style="border:3px solid gray;padding:20px;">

Enter The Year:<input type="text" name="no" value="0" onmouseOver=(value="") onmouseClick=(value=""))><br>

<input type="submit" value="Calculate">

</p>
</center>
</form>
</body>
</html>

Out put


No comments:

Post a Comment