Understanding how much mortgage you can afford is a crucial first step in the home-buying process. This calculator helps you estimate your maximum affordable mortgage amount based on your income, debts, and estimated interest rates. It's important to remember that lenders will also consider your credit score, down payment, and other factors.
function calculateAffordability() {
var annualIncome = parseFloat(document.getElementById("annualIncome").value);
var monthlyDebt = parseFloat(document.getElementById("monthlyDebt").value);
var downPayment = parseFloat(document.getElementById("downPayment").value);
var interestRate = parseFloat(document.getElementById("interestRate").value);
var loanTerm = parseFloat(document.getElementById("loanTerm").value);
var resultDiv = document.getElementById("result");
resultDiv.innerHTML = ""; // Clear previous results
if (isNaN(annualIncome) || isNaN(monthlyDebt) || isNaN(downPayment) || isNaN(interestRate) || isNaN(loanTerm)) {
resultDiv.innerHTML = "Please enter valid numbers for all fields.";
return;
}
// Common lender guideline: Debt-to-Income ratio (DTI)
// Front-end DTI (Housing) typically max 28% of gross income
// Back-end DTI (Total Debt) typically max 36% of gross income
var maxMonthlyHousingPayment = annualIncome / 12 * 0.28;
var maxTotalMonthlyDebt = annualIncome / 12 * 0.36;
var maxAffordableMortgagePayment = maxTotalMonthlyDebt – monthlyDebt;
if (maxAffordableMortgagePayment 0) {
maxLoanAmount = actualMaxMortgagePayment * (1 – Math.pow(1 + monthlyInterestRate, -numberOfPayments)) / monthlyInterestRate;
} else {
// Handle 0% interest rate case (though unlikely for mortgages)
maxLoanAmount = actualMaxMortgagePayment * numberOfPayments;
}
var totalAffordableHomePrice = maxLoanAmount + downPayment;
resultDiv.innerHTML =
"