This calculator helps you determine your target heart rate zone for moderate-intensity exercise, which is typically around 50-70% of your maximum heart rate. For a slightly more vigorous workout, we'll calculate 80% of your maximum heart rate.
Your estimated 80% of Maximum Heart Rate is: — bpm
function calculateTargetHeartRate() {
var age = document.getElementById("ageInput").value;
var resultDisplay = document.getElementById("targetHeartRateResult");
// Clear previous results
resultDisplay.textContent = "– bpm";
// Validate input
if (isNaN(age) || age = 120) {
alert("Please enter a valid age between 1 and 119.");
return;
}
// Calculate estimated Maximum Heart Rate (using the most common formula: 220 – age)
var maxHeartRate = 220 – parseFloat(age);
// Calculate 80% of Maximum Heart Rate
var targetHeartRate = maxHeartRate * 0.80;
// Display the result, rounded to the nearest whole number
resultDisplay.textContent = Math.round(targetHeartRate) + " bpm";
}
#maxHeartRateCalculator {
font-family: sans-serif;
max-width: 400px;
margin: 20px auto;
padding: 15px;
border: 1px solid #ccc;
border-radius: 8px;
background-color: #f9f9f9;
}
#calculatorTitle {
text-align: center;
color: #333;
}
#calculatorDescription {
font-size: 0.9em;
color: #555;
margin-bottom: 20px;
text-align: justify;
}
.input-group {
margin-bottom: 15px;
}
.input-group label {
display: block;
margin-bottom: 5px;
font-weight: bold;
color: #444;
}
.input-group input[type="number"] {
width: calc(100% – 12px);
padding: 8px;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box; /* Include padding and border in the element's total width and height */
}
button {
display: block;
width: 100%;
padding: 10px;
background-color: #007bff;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 1em;
transition: background-color 0.3s ease;
}
button:hover {
background-color: #0056b3;
}
#result {
margin-top: 20px;
padding: 10px;
background-color: #e7f3ff;
border: 1px solid #a0cfff;
border-radius: 4px;
text-align: center;
font-size: 1.1em;
color: #0056b3;
}
#result span {
font-weight: bold;
}