Use this calculator to estimate how much you can afford to borrow for a mortgage. This is a simplified tool and does not account for all factors. Consult with a mortgage lender for a precise pre-approval.
Your Estimated Mortgage Affordability
Maximum Monthly Mortgage Payment: $0.00
Estimated Maximum Loan Amount: $0.00
function calculateMortgageAffordability() {
var monthlyIncome = parseFloat(document.getElementById("monthlyIncome").value);
var currentDebts = parseFloat(document.getElementById("currentDebts").value);
var downPayment = parseFloat(document.getElementById("downPayment").value);
var interestRate = parseFloat(document.getElementById("interestRate").value);
var loanTerm = parseFloat(document.getElementById("loanTerm").value);
var maxDTI = 0.43; // Typical maximum Debt-to-Income ratio
var maxHousingRatio = 0.28; // Typical maximum housing expense ratio
var resultDiv = document.getElementById("result");
var maxMonthlyPaymentSpan = document.getElementById("maxMonthlyPayment");
var maxLoanAmountSpan = document.getElementById("maxLoanAmount");
// Clear previous results
maxMonthlyPaymentSpan.textContent = "$0.00";
maxLoanAmountSpan.textContent = "$0.00";
// Input validation
if (isNaN(monthlyIncome) || isNaN(currentDebts) || isNaN(downPayment) || isNaN(interestRate) || isNaN(loanTerm) ||
monthlyIncome < 0 || currentDebts < 0 || downPayment < 0 || interestRate < 0 || loanTerm <= 0) {
resultDiv.innerHTML = "Please enter valid positive numbers for all fields.";
return;
}
// Calculate maximum allowed monthly debt payment
var maxTotalDebtPayment = monthlyIncome * maxDTI;
// Calculate maximum allowed monthly housing payment
var maxHousingPayment = monthlyIncome * maxHousingRatio;
// Determine the more limiting factor for the monthly mortgage payment
var affordableMonthlyPayment = Math.min(maxHousingPayment, maxTotalDebtPayment – currentDebts);
// Ensure affordable monthly payment is not negative
if (affordableMonthlyPayment 0) {
// Formula for present value of an annuity
maxLoanAmount = affordableMonthlyPayment * (1 – Math.pow(1 + monthlyInterestRate, -numberOfPayments)) / monthlyInterestRate;
} else {
// If interest rate is 0, loan amount is simply monthly payment * number of payments
maxLoanAmount = affordableMonthlyPayment * numberOfPayments;
}
// Subtract down payment to get the maximum affordable home price
var maxAffordableHomePrice = maxLoanAmount + downPayment;
// Display results
maxMonthlyPaymentSpan.textContent = "$" + affordableMonthlyPayment.toFixed(2);
maxLoanAmountSpan.textContent = "$" + maxLoanAmount.toFixed(2);
resultDiv.innerHTML += "Estimated Maximum Affordable Home Price: $" + maxAffordableHomePrice.toFixed(2) + "";
}
#mortgage-calculator {
font-family: sans-serif;
border: 1px solid #ccc;
padding: 20px;
border-radius: 8px;
max-width: 500px;
margin: 20px auto;
background-color: #f9f9f9;
}
#mortgage-calculator h2, #mortgage-calculator h3 {
text-align: center;
color: #333;
margin-bottom: 15px;
}
.input-section {
margin-bottom: 15px;
}
.input-section label {
display: block;
margin-bottom: 5px;
font-weight: bold;
color: #555;
}
.input-section input[type="number"] {
width: calc(100% – 20px);
padding: 10px;
border: 1px solid #ddd;
border-radius: 4px;
box-sizing: border-box;
}
#mortgage-calculator button {
background-color: #4CAF50;
color: white;
padding: 12px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
width: 100%;
margin-top: 10px;
}
#mortgage-calculator button:hover {
background-color: #45a049;
}
.result-section {
margin-top: 25px;
padding-top: 15px;
border-top: 1px dashed #ccc;
text-align: center;
}
.result-section h3 {
margin-bottom: 10px;
}
.result-section p {
font-size: 1.1em;
color: #333;
margin: 5px 0;
}
.result-section span {
font-weight: bold;
color: #0056b3;
}