Mortgage Affordability Calculator
Thinking about buying a home? Our Mortgage Affordability Calculator helps you estimate how much you might be able to borrow based on your income, debts, and desired monthly payment. Understanding your borrowing power is a crucial first step in the home-buying process. This calculator considers your gross monthly income, existing monthly debt payments, and your target monthly mortgage payment (including principal, interest, taxes, and insurance).
function calculateMortgageAffordability() {
var grossMonthlyIncome = parseFloat(document.getElementById("grossMonthlyIncome").value);
var monthlyDebtPayments = parseFloat(document.getElementById("monthlyDebtPayments").value);
var desiredMonthlyPayment = parseFloat(document.getElementById("desiredMonthlyPayment").value);
var resultDiv = document.getElementById("result");
if (isNaN(grossMonthlyIncome) || isNaN(monthlyDebtPayments) || isNaN(desiredMonthlyPayment)) {
resultDiv.innerHTML = "Please enter valid numbers for all fields.";
return;
}
if (grossMonthlyIncome <= 0 || monthlyDebtPayments < 0 || desiredMonthlyPayment <= 0) {
resultDiv.innerHTML = "Please enter positive values for income and desired payment, and a non-negative value for debt payments.";
return;
}
// A common guideline is that total housing costs (PITI) should not exceed 28% of gross monthly income,
// and total debt (housing + other debts) should not exceed 36% of gross monthly income.
// We'll use a more conservative approach based on the desired monthly payment provided by the user
// and ensure it doesn't exceed 36% of their gross income when combined with other debts.
var maxTotalDebtPayment = grossMonthlyIncome * 0.36;
var maxMortgagePaymentAllowed = maxTotalDebtPayment – monthlyDebtPayments;
var estimatedMortgageAffordability = Math.min(desiredMonthlyPayment, maxMortgagePaymentAllowed);
if (estimatedMortgageAffordability < 0) {
resultDiv.innerHTML = "Based on your income and debts, it may be difficult to afford a mortgage payment of $" + desiredMonthlyPayment.toFixed(2) + ". Your maximum affordable mortgage payment is approximately $0.";
} else {
resultDiv.innerHTML = "Based on your inputs, your estimated maximum affordable monthly mortgage payment is approximately
$" + estimatedMortgageAffordability.toFixed(2) + ". This does not include down payment, closing costs, or property taxes and insurance, which will increase your total housing expense.";
}
}
.calculator-container {
font-family: Arial, sans-serif;
border: 1px solid #ddd;
padding: 20px;
border-radius: 8px;
max-width: 600px;
margin: 20px auto;
background-color: #f9f9f9;
}
.calculator-title {
text-align: center;
color: #333;
margin-bottom: 15px;
}
.calculator-description {
color: #555;
line-height: 1.6;
margin-bottom: 25px;
font-size: 0.95em;
}
.calculator-inputs {
display: grid;
grid-template-columns: 1fr;
gap: 15px;
}
.input-group {
display: flex;
flex-direction: column;
}
.input-group label {
margin-bottom: 5px;
font-weight: bold;
color: #444;
}
.input-group input[type="number"] {
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 1em;
width: 100%;
box-sizing: border-box;
}
.calculator-inputs button {
background-color: #4CAF50;
color: white;
padding: 12px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 1.1em;
transition: background-color 0.3s ease;
grid-column: 1 / -1; /* Span across all columns */
margin-top: 10px;
}
.calculator-inputs button:hover {
background-color: #45a049;
}
.calculator-result {
margin-top: 25px;
padding: 15px;
background-color: #e7f3fe;
border-left: 6px solid #2196F3;
color: #333;
font-size: 1.1em;
text-align: center;
}