JavaScript program for leap year

JavaScript program for leap year

Just copy and paste the following function in to script tag inside the header tag so that it can be called from anywhere in this HTML document.
function isleap()
{
 var yr=document.getElementById("year").value;
 if ((parseInt(yr)%4) == 0)
 {
  if (parseInt(yr)%100 == 0)
  {
    if (parseInt(yr)%400 != 0)
    {
    alert("Not Leap");
    return "false";
    }
    if (parseInt(yr)%400 == 0)
    {
    alert("Leap");
    return "true";
    }
  }
  if (parseInt(yr)%100 != 0)
  {
    alert("Leap");
    return "true";
  }
 }
 if ((parseInt(yr)%4) != 0)
 {
    alert("Not Leap");
    return "false";
 } 
} 

Comments

Popular posts from this blog

ISP and TCP/IP