Script Categories













Calculators >>> Leap Year.

Is it a leap year? What about in 1900? Get your leap year facts straight with this leap year calculator. Just enter the year you are interested in and the script reports whether it is a leap year or not. Or, enter a range of years and JavaScript will display all the leap years in that range.

Check For Leap Year:
Year: is


Leap Years Within A Range:
Start Year:
End year:


Add the below code to the <body> section of your page:

<script language="javascript" type="text/javascript">
/* Visit http://www.yaldex.com/ for full source code
and get more free JavaScript, CSS and DHTML scripts! */
<!-- Begin
function checkYear(year) {
return (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) ? 1 : 0;
}
function leap(form) {
year = form.year.value;
var Check1 = parseFloat(year);
for (var i = 0; i < year.length; i++) {
var sLetterCheck1 = year.substring(i, i+1);
if (sLetterCheck1 < "0" || sLetterCheck1 > "9") {
alert("Enter a valid year.");
form.year.focus();
form.year.select();
return;
   }
}
      
if (year < 1582) {
form.result.value = "";
alert("Year must be greater than 1581.");
form.year.focus();
form.year.select();
return;
}
checkYear(year);
if (!checkYear(year)) form.result.value = "not a leap year.";
else form.result.value = "a leap year.";
}
function MakeArray(n) {
if (n <= 0) {
this.length = 0;
return this;
}
this.length = n;
for (var i = 1; i <= n; i++) {
this[i] = 0;
}
return this;
}
var listArray = new MakeArray(160);
var index = 0;
function list(form) {
startyear = form.startyear.value;
endyear = form.endyear.value;
var Check1 = parseFloat(startyear);
var Check2 = parseFloat(endyear);
for (var i = 0; i < startyear.length; i++) {
var sLetterCheck1 = startyear.substring(i, i+1);
if (sLetterCheck1 < "0" || sLetterCheck1 > "9") {
alert("Enter a valid start year.");
form.startyear.focus();
form.startyear.select();
return;
   }
}
      
for (var i = 0; i < endyear.length; i++) {
var sLetterCheck2 = endyear.substring(i, i+1);
if (sLetterCheck2 < "0" || sLetterCheck2 > "9") {
alert("Enter a valid end year.");
form.endyear.focus();
form.endyear.select();
return;
   }
}
      
if (startyear < 1582) {
form.yearlist.value = "";
alert("Start year must be greater than 1581.");
form.startyear.focus();
form.startyear.select();
return;
}
else if (endyear <= startyear) {
form.yearlist.value = "";
alert("End year must be greater than start year.");
form.endyear.focus();
form.endyear.select();
return;
}
else {
index = 0;
for (var i=startyear; i <=endyear; i++) {
if (checkYear(i)) {
listArray[index] = i;
index++;
      }
   }
}
var allYears;
allYears = "";
for( i = 0; i < index; i++ ) {
allYears += listArray[i] + "\r" + "\n";
form.yearlist.value = allYears;
   }
}
//  End -->
</script>
<form>
Check For Leap Year:<br>
Year:  <input type=text name=year size=4> is <input type=text name=result size=15>
<br>
<
br>
<input type=button value="Check Year" onClick="leap(this.form);">
<br>
Leap Years Within A Range:<br>
Start Year:<input type=text name=startyear size=4><br>
End year: <input type="text" name="endyear" size=4><br>
<
br>
<input type=button name=listyears value="List Years" onClick="list(this.form);">
<br>
<textarea name=yearlist rows=10 cols=11></textarea>
</form>

JavaScript Editor Get Advanced
JavaScript and Ajax Editor,
Validator and Debugger!

1st JavaScript Editor.



Code was highlighted by 1st JavaScript Editor (The Best JavaScript Editor!).

Модульные кухни от производителя недорого в москве xorekmebel.ru. . R7


©