function calculateAffordability() {
// Get Input Values
var incomeInput = document.getElementById('annualIncome');
var debtInput = document.getElementById('monthlyDebt');
var downPaymentInput = document.getElementById('downPayment');
var rateInput = document.getElementById('interestRate');
var termInput = document.getElementById('loanTerm');
var taxInsInput = document.getElementById('monthlyTaxIns');
var errorDiv = document.getElementById('macError');
var resultsDiv = document.getElementById('macResults');
var annualIncome = parseFloat(incomeInput.value);
var monthlyDebt = parseFloat(debtInput.value);
var downPayment = parseFloat(downPaymentInput.value);
var interestRate = parseFloat(rateInput.value);
var years = parseFloat(termInput.value);
var taxIns = parseFloat(taxInsInput.value);
// Validation
if (isNaN(annualIncome) || isNaN(monthlyDebt) || isNaN(downPayment) || isNaN(interestRate) || isNaN(years) || isNaN(taxIns)) {
errorDiv.style.display = 'block';
resultsDiv.style.display = 'none';
return;
} else {
errorDiv.style.display = 'none';
resultsDiv.style.display = 'block';
}
// Logic based on Standard DTI Rules (28/36 Rule)
var monthlyGrossIncome = annualIncome / 12;
// Front-end limit: 28% of gross income usually goes to housing
var maxHousingPaymentFront = monthlyGrossIncome * 0.28;
// Back-end limit: 36% of gross income for total debt (housing + other debts)
var maxTotalDebtPayment = monthlyGrossIncome * 0.36;
var maxHousingPaymentBack = maxTotalDebtPayment – monthlyDebt;
// The bank will lend based on the lower of the two
var maxAllowedMonthlyPayment = Math.min(maxHousingPaymentFront, maxHousingPaymentBack);
// Available for Principal & Interest (P&I) = Max Payment – Taxes/Insurance
var availableForPI = maxAllowedMonthlyPayment – taxIns;
var maxLoanAmount = 0;
var maxHomePrice = 0;
var monthlyPI = 0;
if (availableForPI > 0) {
// Mortgage Calculation: P = (M * (1 – (1+r)^-n)) / r
var r = (interestRate / 100) / 12;
var n = years * 12;
if (r === 0) {
maxLoanAmount = availableForPI * n;
} else {
maxLoanAmount = availableForPI * ( (1 – Math.pow(1 + r, -n)) / r );
}
maxHomePrice = maxLoanAmount + downPayment;
monthlyPI = availableForPI;
} else {
maxLoanAmount = 0;
maxHomePrice = downPayment; // Only afford what you have cash for if debt is too high
monthlyPI = 0;
}
// Display Results
document.getElementById('maxHomePrice').innerText = '$' + Math.floor(maxHomePrice).toLocaleString();
document.getElementById('maxLoanAmount').innerText = '$' + Math.floor(maxLoanAmount).toLocaleString();
document.getElementById('monthlyPI').innerText = '$' + Math.floor(monthlyPI).toLocaleString();
// Calculate Ratios for display
var actualHousingCost = monthlyPI + taxIns;
var frontRatio = (actualHousingCost / monthlyGrossIncome) * 100;
var backRatio = ((actualHousingCost + monthlyDebt) / monthlyGrossIncome) * 100;
document.getElementById('frontEndRatio').innerText = frontRatio.toFixed(1) + '% (Limit 28%)';
document.getElementById('backEndRatio').innerText = backRatio.toFixed(1) + '% (Limit 36%)';
}
How Much House Can You Really Afford?
Determining your home buying power is the first critical step in the homeownership journey. This Mortgage Affordability Calculator uses the standard debt-to-income (DTI) ratios utilized by lenders to estimate a realistic home price based on your finances.
Understanding the 28/36 Rule
Lenders typically use two main ratios to decide how much money to lend:
Front-End Ratio (28%): This rule suggests that your monthly housing costs (principal, interest, taxes, and insurance) should not exceed 28% of your gross monthly income.
Back-End Ratio (36%): This ratio looks at your total monthly debt burden. Your housing costs plus all other recurring debts (credit cards, student loans, car payments) should not exceed 36% of your gross monthly income.
Our calculator computes both limits and uses the lower (more conservative) number to determine your maximum loan amount.
The Impact of Interest Rates
Interest rates play a massive role in affordability. A difference of just 1% in your mortgage rate can significantly alter your buying power. As rates rise, the portion of your monthly payment going toward interest increases, reducing the loan amount you can support with the same monthly income.
Why Down Payments Matter
Your down payment does more than just reduce the loan amount. It directly increases your maximum home price dollar-for-dollar on top of what the bank is willing to lend. Furthermore, a down payment of 20% or more often eliminates the need for Private Mortgage Insurance (PMI), freeing up more of your monthly cash flow for the mortgage principal.
Before You Apply
While this calculator provides a solid estimate, keep in mind that lenders also look at credit scores, employment history, and cash reserves. To maximize your affordability, consider paying down high-interest consumer debt before applying for a mortgage to improve your back-end DTI ratio.