This calculator helps you estimate how much you can afford to borrow for a mortgage. It considers your income, debts, and down payment to give you a rough idea of your borrowing capacity. Remember, this is an estimate, and your actual approved loan amount may vary based on the lender's specific criteria and your creditworthiness.
.calculator-container {
font-family: sans-serif;
max-width: 600px;
margin: 20px auto;
padding: 20px;
border: 1px solid #ccc;
border-radius: 8px;
background-color: #f9f9f9;
}
.calculator-container h2 {
text-align: center;
color: #333;
margin-bottom: 15px;
}
.calculator-container p {
text-align: justify;
color: #555;
margin-bottom: 25px;
line-height: 1.6;
}
.input-section {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 15px;
margin-bottom: 20px;
}
.input-section label {
display: block;
margin-bottom: 5px;
font-weight: bold;
color: #444;
}
.input-section input {
width: 100%;
padding: 10px;
border: 1px solid #ddd;
border-radius: 4px;
box-sizing: border-box;
}
button {
display: block;
width: 100%;
padding: 12px 20px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
transition: background-color 0.3s ease;
}
button:hover {
background-color: #45a049;
}
.result-section {
margin-top: 20px;
padding: 15px;
background-color: #e7f3fe;
border: 1px solid #b3d4fc;
border-radius: 4px;
text-align: center;
font-size: 1.1em;
color: #333;
}
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)) {
resultDiv.innerHTML = "Please enter valid numbers for all fields.";
return;
}
// General affordability guidelines:
// 1. Front-end ratio (housing expenses): typically no more than 28% of gross monthly income.
// 2. Back-end ratio (total debt): typically no more than 36% of gross monthly income.
// We'll use a conservative approach, assuming lenders might be stricter.
// A common rule of thumb for maximum monthly mortgage payment (PITI) is around 28% of gross monthly income.
// A common rule of thumb for total debt payments (including mortgage) is around 36% of gross monthly income.
var grossMonthlyIncome = annualIncome / 12;
var maxMonthlyPaymentFromIncome = grossMonthlyIncome * 0.28; // Max for PITI
var maxTotalMonthlyDebt = grossMonthlyIncome * 0.36; // Max for all debts
// Calculate the maximum affordable monthly mortgage payment, considering total debt
var affordableMonthlyMortgagePayment = maxTotalMonthlyDebt – monthlyDebt;
// Ensure the affordable payment doesn't exceed the income-based limit
affordableMonthlyMortgagePayment = Math.min(affordableMonthlyMortgagePayment, maxMonthlyPaymentFromIncome);
if (affordableMonthlyMortgagePayment 0 && numberOfPayments > 0) {
var numerator = Math.pow((1 + monthlyInterestRate), numberOfPayments) – 1;
var denominator = monthlyInterestRate * Math.pow((1 + monthlyInterestRate), numberOfPayments);
maximumLoanAmount = affordableMonthlyMortgagePayment * (numerator / denominator);
} else if (monthlyInterestRate === 0 && numberOfPayments > 0) {
// If interest rate is 0, the loan amount is simply monthly payment * number of payments
maximumLoanAmount = affordableMonthlyMortgagePayment * numberOfPayments;
}
var maxAffordableHomePrice = maximumLoanAmount + downPayment;
// Format results for display
var formattedAnnualIncome = annualIncome.toLocaleString('en-US', { style: 'currency', currency: 'USD' });
var formattedMonthlyDebt = monthlyDebt.toLocaleString('en-US', { style: 'currency', currency: 'USD' });
var formattedDownPayment = downPayment.toLocaleString('en-US', { style: 'currency', currency: 'USD' });
var formattedMaxAffordableHomePrice = maxAffordableHomePrice.toLocaleString('en-US', { style: 'currency', currency: 'USD' });
var formattedMaxLoanAmount = maximumLoanAmount.toLocaleString('en-US', { style: 'currency', currency: 'USD' });
var formattedAffordableMonthlyMortgagePayment = affordableMonthlyMortgagePayment.toLocaleString('en-US', { style: 'currency', currency: 'USD' });
resultDiv.innerHTML = `
Based on your inputs:
Annual Household Income: ${formattedAnnualIncome}
Total Monthly Debt: ${formattedMonthlyDebt}
Down Payment: ${formattedDownPayment}
Estimated Maximum Loan Amount: ${formattedMaxLoanAmount}
Estimated Maximum Home Price You Can Afford: ${formattedMaxAffordableHomePrice}
Estimated Maximum Monthly Mortgage Payment (PITI): ${formattedAffordableMonthlyMortgagePayment}
Disclaimer: This is an estimate. Lenders will consider credit score, employment history, property taxes, homeowner's insurance, and other factors. Consult with a mortgage professional for a precise pre-approval.
`;
}