JavaScript Scripts





Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
Free Java Script Codes
Javascript List All
Slide Show Slide Show
Ad Display Ad Display
Image Effect Image Effect
Animated Image Effects Animated Image Effects
Form Validation Form Validation
Color Picker Tool Color Picker Tool
Formatting Forms Formatting Forms
Select All Select All
Dynamic Form Select Dynamic Form select
Dynamic Color Dynamic Color
Dynamic Color Calendar
Textbox Counter Textbox Counter
Alphanumeric Alphanumeric
Date Time Script Date & Time
Stop Watch Script Stop Watch script
Delete Repeated Values Delete Repeated Values
Pagination Pagination
Random Generator Random Generator
Animated Text Animated Text
Cursor Position Cursor Position
User Info Window / User Info
Security Security / Authenticate
Bookmark Bookmark
Mouse Effects Mouse Effects
Title Bar Title Bar
Status Bar Status Bar
Country List Country List
Free Games Free Games
Calculators Calculators
 




Leap Year


About
This script function will validate the given year for leap year.


Features
a)The javascript function will return true if the passed argument is a leap year else returns false.
b)Just copy the code in to your page and use it.

Preview
Enter a year [ ex: 2020 ] -


Code
<!-- Script by hscripts.com -->
<script type="text/javascript">
function checkleapyear(datea)
{
       datea = parseInt(datea);
        if(datea%4 == 0)
        {
                if(datea%100 != 0)
                {
                        return true;
                }
                else
                {
                        if(datea%400 == 0)
                                return true;
                        else
                                return false;
                }
        }
return false;
}

function isLeapYear()
{
        var df = document.sd.yv.value;
        if(df!= "" && parseInt(df))
        {
                var res = checkleapyear(df);
                if(res)
                {
                 document.sd.val.style.color = "green";
                 document.sd.val.value = df+" is a leap year";
                }
                else
                {
                 document.sd.val.style.color = "#9a235d";
                 document.sd.val.value = df+" is  not a leap year";
          document.sd.val.value = df+" is  not a leap year";
                }
        }
        else
        {
                alert("Enter a proper value");
        }

return false;
}
function isInteger(s)
{
      var i;
	s = s.toString();
      for (i = 0; i < s.length; i++)
      {
         var c = s.charAt(i);
         if (isNaN(c)) 
	   {
		alert("Given value is not a number");
		return false;
	   }
      }
      return true;
}

</script>
<form name=sd method=post action="" onsubmit="return isLeapYear()">
Enter a year [ ex: 2020 ] - <input name=yv type=text onKeyup="isInteger(this.value)"><input type=submit value=go><br>
<input type=text name=val size=30 style="background-color:white; border:0px; margin:0px; color: #9a235d;" readonly>
</form>
<!-- Script by hscripts.com -->

Release Date - 5-2-2005
Get free version without ©copyright link for just 5 price

For customization of this script or any script development, contact us at support@hscripts.com


Usage
Just copy the code and use it for free.



License
- The javascript (misspelled as java script) is given under GPL License
- i.e. Free use for those who use the codes as it is.
- Free, if your modification does not remove our copyright information and links.
- Click Here for detailed license information.
- You can purchase the script if your requirements does not meet our GPL License terms.
Other Links

web hosting