Skip to content

Instantly share code, notes, and snippets.

@Ashvith07
Last active September 27, 2020 02:34
Show Gist options
  • Save Ashvith07/2ac14586d2763074827e to your computer and use it in GitHub Desktop.
Save Ashvith07/2ac14586d2763074827e to your computer and use it in GitHub Desktop.
<html>
<head>
<title> The Age Calculator</title>
</head>
<body>
<script language="JavaScript">
function CalculateAge()
{
var birthyear = document.form1.txt.value;
var currentyear = new Date();
var age = currentyear.getFullYear();
document.write('They are either ' + (age-birthyear)+ ' or ' + (age-birthyear - 1));
}
</script>
<form name=form1>
Enter the Birth Year
<input type="text" name="txt" size=10>
<br>
<input type="button" value="Calculate" onClick='CalculateAge();'>
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment