This calculator helps you estimate the maximum mortgage you can afford based on your income, debts, and desired down payment. It considers common lending ratios and interest rates to give you a realistic idea of your borrowing power.
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 propertyTaxRate = parseFloat(document.getElementById("propertyTaxRate").value);
var homeInsurance = parseFloat(document.getElementById("homeInsurance").value);
var pmi = parseFloat(document.getElementById("pmi").value);
var errorMessage = "";
if (isNaN(annualIncome) || annualIncome <= 0) {
errorMessage += "Please enter a valid Annual Gross Income.";
}
if (isNaN(monthlyDebt) || monthlyDebt < 0) {
errorMessage += "Please enter a valid Total Monthly Debt Payments.";
}
if (isNaN(downPayment) || downPayment < 0) {
errorMessage += "Please enter a valid Down Payment.";
}
if (isNaN(interestRate) || interestRate 20) {
errorMessage += "Please enter a valid Estimated Annual Interest Rate between 1% and 20%.";
}
if (isNaN(loanTerm) || loanTerm 50) {
errorMessage += "Please enter a valid Loan Term between 1 and 50 years.";
}
if (isNaN(propertyTaxRate) || propertyTaxRate 5) {
errorMessage += "Please enter a valid Estimated Annual Property Tax Rate between 0% and 5%.";
}
if (isNaN(homeInsurance) || homeInsurance < 0) {
errorMessage += "Please enter a valid Estimated Annual Homeowner's Insurance.";
}
if (isNaN(pmi) || pmi < 0) {
errorMessage += "Please enter a valid Estimated Annual PMI.";
}
if (errorMessage !== "") {
document.getElementById("result").innerHTML = "" + errorMessage + "";
return;
}
// Lender's affordability ratios (common guidelines, can vary)
var maxDebtToIncomeRatio = 0.43; // 43%
var maxHousingRatio = 0.28; // 28% (PITI / Gross Monthly Income)
var grossMonthlyIncome = annualIncome / 12;
// Calculate maximum housing payment (PITI) based on housing ratio
var maxPitiPayment = grossMonthlyIncome * maxHousingRatio;
// Calculate maximum total debt payment based on debt-to-income ratio
var maxTotalDebtPayment = grossMonthlyIncome * maxDebtToIncomeRatio;
// Maximum allowable mortgage payment (principal & interest only)
// This is the maximum PITI minus taxes, insurance, and PMI
var maxMortgagePayment = maxPitiPayment – (propertyTaxRate * (annualIncome/12)/100) – (homeInsurance/12) – (pmi/12); // Adjusting for monthly amounts
// Ensure maxMortgagePayment is not negative
if (maxMortgagePayment 0 && monthlyInterestRate > 0 && numberOfPayments > 0) {
// Mortgage payment formula: M = P [ i(1 + i)^n ] / [ (1 + i)^n – 1]
// Solving for P (Principal): P = M [ (1 + i)^n – 1] / [ i(1 + i)^n ]
maxLoanAmount = maxMortgagePayment * (Math.pow(1 + monthlyInterestRate, numberOfPayments) – 1) / (monthlyInterestRate * Math.pow(1 + monthlyInterestRate, numberOfPayments));
}
// The maximum affordable home price is the max loan amount plus the down payment
var maxAffordablePrice = maxLoanAmount + downPayment;
// Calculate the total monthly debt (including estimated mortgage) to check against the DTI ratio
var estimatedMonthlyMortgagePayment = maxMortgagePayment; // This is already calculated based on the max PITI
var totalMonthlyObligations = monthlyDebt + estimatedMonthlyMortgagePayment;
// Check if the total monthly obligations exceed the maxTotalDebtPayment limit.
// If it does, we might need to reduce the estimated mortgage payment, which means a lower loan amount and thus a lower affordable price.
// This is a simplified check. In reality, lenders analyze specific debt types.
var adjustedMaxLoanAmount = maxLoanAmount;
var adjustedMaxAffordablePrice = maxAffordablePrice;
if (totalMonthlyObligations > maxTotalDebtPayment && maxMortgagePayment > 0) {
var reductionNeeded = totalMonthlyObligations – maxTotalDebtPayment;
// Reduce the estimated monthly mortgage payment by the amount exceeding the DTI
var reducedMortgagePayment = maxMortgagePayment – reductionNeeded;
if (reducedMortgagePayment 0 && monthlyInterestRate > 0 && numberOfPayments > 0) {
adjustedMaxLoanAmount = reducedMortgagePayment * (Math.pow(1 + monthlyInterestRate, numberOfPayments) – 1) / (monthlyInterestRate * Math.pow(1 + monthlyInterestRate, numberOfPayments));
} else {
adjustedMaxLoanAmount = 0;
}
adjustedMaxAffordablePrice = adjustedMaxLoanAmount + downPayment;
}
document.getElementById("result").innerHTML =
"
Estimated Mortgage Affordability
" +
"Based on your inputs, your estimated maximum affordable home price is: $" + maxAffordablePrice.toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ",") + "" +
"This includes your down payment of $" + downPayment.toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ",") + "." +
"The estimated maximum loan amount you might qualify for is: $" + maxLoanAmount.toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ",") + "" +
"This estimation is based on:" +
"
" +
"
A maximum PITI (Principal, Interest, Taxes, Insurance, PMI) payment of $" + maxPitiPayment.toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ",") + " per month (approx. " + (maxHousingRatio * 100).toFixed(0) + "% of your gross monthly income).
" +
"
A maximum total monthly debt payment (including estimated PITI) of $" + maxTotalDebtPayment.toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ",") + " per month (approx. " + (maxDebtToIncomeRatio * 100).toFixed(0) + "% of your gross monthly income).
" +
"
Estimated monthly costs for property taxes, homeowner's insurance, and PMI: