Use this calculator to estimate the maximum mortgage you can afford. This is a simplified tool and doesn't account for all lender requirements or closing costs. It's always best to speak with a mortgage professional for a precise pre-approval.
.calculator-container {
font-family: sans-serif;
border: 1px solid #ccc;
padding: 20px;
border-radius: 8px;
max-width: 500px;
margin: 20px auto;
background-color: #f9f9f9;
}
.calculator-container h2 {
text-align: center;
margin-bottom: 15px;
color: #333;
}
.calculator-container p {
font-size: 0.9em;
color: #555;
text-align: center;
margin-bottom: 25px;
}
.input-section {
display: grid;
grid-template-columns: 1fr;
gap: 15px;
margin-bottom: 20px;
}
.input-section label {
font-weight: bold;
display: block;
margin-bottom: 5px;
color: #444;
}
.input-section input[type="number"] {
width: 100%;
padding: 10px;
border: 1px solid #ddd;
border-radius: 4px;
box-sizing: border-box;
}
.calculator-container button {
display: block;
width: 100%;
padding: 12px 20px;
background-color: #007bff;
color: white;
border: none;
border-radius: 4px;
font-size: 1.1em;
cursor: pointer;
transition: background-color 0.3s ease;
}
.calculator-container button:hover {
background-color: #0056b3;
}
.result-section {
margin-top: 25px;
padding: 15px;
background-color: #e9ecef;
border: 1px solid #ced4da;
border-radius: 4px;
text-align: center;
font-size: 1.1em;
color: #333;
}
.result-section strong {
color: #007bff;
}
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");
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;
}
// Debt-to-Income Ratio (DTI) is a common metric lenders use.
// A common guideline is a maximum DTI of 43%, including PITI (Principal, Interest, Taxes, Insurance).
// We'll estimate the maximum PITI based on income, then work backwards.
var maxMonthlyHousingPayment = (annualIncome * 0.43) – monthlyDebt;
if (maxMonthlyHousingPayment 0 && numberOfPayments > 0) {
var factor = Math.pow(1 + monthlyInterestRate, numberOfPayments);
loanAmount = maxMonthlyHousingPayment * (factor – 1) / (monthlyInterestRate * factor);
} else if (monthlyInterestRate === 0) { // Handle 0% interest rate scenario
loanAmount = maxMonthlyHousingPayment * numberOfPayments;
}
var maxPurchasePrice = loanAmount + downPayment;
resultDiv.innerHTML = "Estimated Maximum Mortgage Loan Amount: $" + loanAmount.toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ",") + "" +
"Estimated Maximum Purchase Price: $" + maxPurchasePrice.toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ",") + "" +
"Note: This estimate uses a DTI of 43% and does NOT include property taxes, homeowner's insurance, or PMI, which would reduce your affordable loan amount.";
}