Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
fab3F committed Oct 30, 2023
1 parent 84da3a8 commit a592bc5
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions js/agecalc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ function calculateAge() {

const ageMilliseconds = currentDate - birthdate;
const ageYears = ageMilliseconds / (1000 * 60 * 60 * 24 * 365.25);

output.innerHTML = "Dein aktuelle Alter beträgt " + ageYears.toFixed(10) + " Jahre."
if(input.value)
output.innerHTML = "Dein aktuelles Alter in Jahren beträgt: " + ageYears.toFixed(10);
}

// Set max attribute to today's date
const today = new Date();
const todayString = today.toISOString().split('T')[0];
const birthdateInput = document.getElementById("input");
birthdateInput.max = todayString;

// Update age on input change
birthdateInput.addEventListener("input", setInterval(calculateAge, 10));
setInterval(calculateAge, 50);

0 comments on commit a592bc5

Please sign in to comment.