Can anyone assist with my code. I just cannot get this to work:
I have to write a script that allows the user to enter a year & then determine whether it is a leap year or not. The request is for a form with a single text box and using an alert dialog box stating if the entered year is a standard or leap year.
Code so far:
[HTML]<HTML>
<HEAD>
<TITLE>Is it a leap year?</TITLE>
</HEAD>
<SCRIPT LANGUAGE="JAVAS CRIPT>
<!-- Hide from old browsers
function leapYear(){
Last2Digits = year % 100
if (Last2Digits == 0):
flag = year % 400
else:
flag = year % 4
if (flag == 0) :
window.alert("T he year you have entered is a leap year.")
else:
window.alert("T he year you have entered is a standard year.")
}
//-->
</script>
</head>
<body>
<form><p>Year : <input type="text" name="Year"></p>
<input type="button" value="Check for Leap Year" name="check for leap year" onclick="leapYe ar()">
</form>
</body>[/HTML]
I have to write a script that allows the user to enter a year & then determine whether it is a leap year or not. The request is for a form with a single text box and using an alert dialog box stating if the entered year is a standard or leap year.
Code so far:
[HTML]<HTML>
<HEAD>
<TITLE>Is it a leap year?</TITLE>
</HEAD>
<SCRIPT LANGUAGE="JAVAS CRIPT>
<!-- Hide from old browsers
function leapYear(){
Last2Digits = year % 100
if (Last2Digits == 0):
flag = year % 400
else:
flag = year % 4
if (flag == 0) :
window.alert("T he year you have entered is a leap year.")
else:
window.alert("T he year you have entered is a standard year.")
}
//-->
</script>
</head>
<body>
<form><p>Year : <input type="text" name="Year"></p>
<input type="button" value="Check for Leap Year" name="check for leap year" onclick="leapYe ar()">
</form>
</body>[/HTML]
Comment