function calculateAffordability() {
var annualIncome = parseFloat(document.getElementById('annualIncome').value);
var monthlyDebts = parseFloat(document.getElementById('monthlyDebts').value);
var downPayment = parseFloat(document.getElementById('downPayment').value);
var annualRate = parseFloat(document.getElementById('interestRate').value);
var loanTermYears = parseFloat(document.getElementById('loanTerm').value);
var escrow = parseFloat(document.getElementById('escrow').value);
if (isNaN(annualIncome) || isNaN(monthlyDebts) || isNaN(downPayment) || isNaN(annualRate)) {
alert("Please enter valid numeric values.");
return;
}
// Financial Rule: Debt-to-Income (DTI) should not exceed 36% for a conservative estimate
var monthlyGrossIncome = annualIncome / 12;
var maxAllowedMonthlyDebtTotal = monthlyGrossIncome * 0.36;
// Subtract existing debts and estimated tax/insurance from the allowed total
var maxMonthlyPI = maxAllowedMonthlyDebtTotal – monthlyDebts – escrow;
if (maxMonthlyPI <= 0) {
document.getElementById('resultsArea').style.display = 'block';
document.getElementById('maxPrice').innerHTML = "Limited Affordability";
document.getElementById('monthlyPaymentResult').innerHTML = "$0";
document.getElementById('loanAmountResult').innerHTML = "$0";
return;
}
// Mortgage Formula: P = L[c(1 + c)^n] / [(1 + c)^n – 1]
// We need to solve for Loan (L): L = P * [ (1 + c)^n – 1 ] / [ c(1 + c)^n ]
var monthlyRate = (annualRate / 100) / 12;
var numberOfPayments = loanTermYears * 12;
var loanAmount = maxMonthlyPI * (Math.pow(1 + monthlyRate, numberOfPayments) – 1) / (monthlyRate * Math.pow(1 + monthlyRate, numberOfPayments));
var totalHomePrice = loanAmount + downPayment;
// Display Results
document.getElementById('resultsArea').style.display = 'block';
document.getElementById('maxPrice').innerHTML = "$" + Math.round(totalHomePrice).toLocaleString();
document.getElementById('monthlyPaymentResult').innerHTML = "$" + Math.round(maxMonthlyPI + escrow).toLocaleString();
document.getElementById('loanAmountResult').innerHTML = "$" + Math.round(loanAmount).toLocaleString();
}
How Home Affordability is Calculated
Understanding how much home you can afford is the most critical step in the home-buying process. Our calculator uses the Debt-to-Income (DTI) ratio, a standard metric used by lenders to evaluate your borrowing capacity.
The 36% Rule
Most financial experts recommend that your total monthly debt payments—including your new mortgage, property taxes, home insurance, car loans, and credit card payments—should not exceed 36% of your gross monthly income. Our calculator applies this conservative threshold to ensure you don't become "house poor."
- Gross Income: Your total earnings before taxes and deductions.
- Monthly Debts: Fixed obligations like student loans, auto loans, and minimum credit card payments.
- Escrow: An estimate for property taxes and homeowners insurance, which vary by location but significantly impact your monthly budget.
Example Scenario
If a household earns $100,000 annually, their gross monthly income is approximately $8,333. Using the 36% rule, the total allowed debt is $3,000 per month. If that household has $500 in car payments and expects $400 in taxes/insurance, they have $2,100 available for the principal and interest of their mortgage. At a 6.5% interest rate for 30 years, this translates to roughly a $332,000 loan. Adding a $50,000 down payment brings the total affordable home price to $382,000.
Note: While this calculator provides a strong estimate, mortgage lenders may use different DTI limits (up to 43% or even 50% for certain loan types) and will also consider your credit score and employment history.