H I O X INDIA
FREE Javascript
 HOME  ||  Scripts  ||  Purchase  ||  Tutorials  ||  Images  ||  Tools  ||  Templates 
  :-)  Send Page   :-)   Feedback   :-)   Register   :-)   Links   :-)   Support   :-)
Español Français 中文 Deutsch
 Forums   Hosting   Internet Stats   Easy Calculation   FUN Games 

Java Script Source
List All
Date & Time
Calendar
Stop Watch script
Slide Show
Ad Display
Animated Image Effects
Image Effect
Mouse Effects
Color Picker Tool
Dynamic Color
Random Generator
Select All
Form Validation
Formatting Forms
Textbox Counter
Dynamic Form select
Bookmark
Window / User Info
Pagination
Security / Authenticate
Status Bar
Title Bar
Cursor Position
Country List
Calculators
Delete Repeated Values
Alphanumeric
Free Games




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 language="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



Usage
Just copy the code and use it for free.





License
- This javascript (misspelled as java script)/HTML code is given under GPL License
- i.e. Free use for those who use it as it is.
- Free, if your modification does not remove our copyright information and links.
- Detailed License information can be found here
- You can purchase the script if your requirements does not meet GPL License terms.


privacy policy     license     sitemap
© 2004-2005 HIOX INDIA - hioxindia.com

Others