A golden birthday is a special occasion that happens only once in a person's life. It occurs when you celebrate your birthday on the same date as your birth date, but in a year where your age numerically matches the day of the month you were born. For example, if you were born on the 15th of a month, your golden birthday is when you turn 15 years old. This calculator helps you determine if you've had, are currently experiencing, or will have a golden birthday.
function calculateGoldenBirthday() {
var birthDayInput = document.getElementById("birthDay");
var currentAgeInput = document.getElementById("currentAge");
var resultDiv = document.getElementById("result");
var birthDay = parseInt(birthDayInput.value);
var currentAge = parseInt(currentAgeInput.value);
resultDiv.innerHTML = ""; // Clear previous results
if (isNaN(birthDay) || isNaN(currentAge) || birthDay 31 || currentAge 0) {
resultDiv.innerHTML = "Your Golden Birthday will be when you turn " + goldenBirthdayAge + " years old. That's in " + ageDifference + " year(s).";
} else {
resultDiv.innerHTML = "You have already celebrated your Golden Birthday when you turned " + goldenBirthdayAge + " years old.";
}
}
.calculator-container {
font-family: sans-serif;
border: 1px solid #ccc;
padding: 20px;
border-radius: 8px;
max-width: 500px;
margin: 20px auto;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.calculator-container h2 {
text-align: center;
margin-bottom: 15px;
color: #333;
}
.calculator-container p {
line-height: 1.6;
color: #555;
margin-bottom: 20px;
}
.input-section {
margin-bottom: 15px;
}
.input-section label {
display: block;
margin-bottom: 5px;
font-weight: bold;
color: #444;
}
.input-section input {
width: calc(100% – 22px);
padding: 10px;
border: 1px solid #ddd;
border-radius: 4px;
font-size: 16px;
}
.calculator-container button {
display: block;
width: 100%;
padding: 12px;
background-color: #007bff;
color: white;
border: none;
border-radius: 4px;
font-size: 18px;
cursor: pointer;
transition: background-color 0.3s ease;
}
.calculator-container button:hover {
background-color: #0056b3;
}
#result {
margin-top: 20px;
padding: 15px;
background-color: #f8f9fa;
border: 1px solid #e9ecef;
border-radius: 4px;
text-align: center;
}
#result p {
margin: 0;
}