This calculator helps you estimate how much you can potentially borrow for a mortgage based on your income, debts, and desired down payment. It's important to remember that this is an estimation, and lenders will consider many other factors, including your credit score, employment history, and current market conditions.
function calculateMortgageAffordability() {
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) ||
annualIncome <= 0 || monthlyDebt < 0 || downPayment < 0 || interestRate <= 0 || loanTerm <= 0) {
resultDiv.innerHTML = "Please enter valid positive numbers for all fields.";
return;
}
// General affordability rule of thumb: Debt-to-Income (DTI) ratio.
// Lenders often look for a total DTI (including potential mortgage) below 43%.
// Let's estimate maximum affordable monthly P&I (Principal & Interest) payment.
var maxTotalMonthlyObligations = annualIncome / 12 * 0.43; // 43% of gross monthly income
var maxMonthlyMortgagePayment = maxTotalMonthlyObligations – monthlyDebt;
if (maxMonthlyMortgagePayment 0) {
// Rearrange the formula to solve for P:
// P = M [ (1 + i)^n – 1] / [ i(1 + i)^n ]
var term = Math.pow(1 + monthlyInterestRate, numberOfPayments);
maxLoanAmount = maxMonthlyMortgagePayment * (term – 1) / (monthlyInterestRate * term);
} else {
// If interest rate is 0%, loan amount is simply monthly payment * number of payments
maxLoanAmount = maxMonthlyMortgagePayment * numberOfPayments;
}
var estimatedHomePrice = maxLoanAmount + downPayment;
resultDiv.innerHTML = "