#seo-calc-wrapper * { box-sizing: border-box; }
#seo-calc-header { background: #2c3e50; color: #fff; padding: 20px; text-align: center; }
#seo-calc-header h2 { margin: 0; font-size: 24px; font-weight: 600; }
#seo-calc-body { padding: 25px; display: flex; flex-wrap: wrap; gap: 30px; }
.seo-calc-col { flex: 1; min-width: 280px; }
.seo-input-group { margin-bottom: 15px; }
.seo-input-group label { display: block; margin-bottom: 5px; font-weight: 600; color: #333; font-size: 14px; }
.seo-input-group input { width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 4px; font-size: 16px; transition: border-color 0.3s; }
.seo-input-group input:focus { border-color: #3498db; outline: none; }
.seo-input-row { display: flex; gap: 10px; }
.seo-input-row .seo-input-group { flex: 1; }
#seo-calc-btn { width: 100%; padding: 12px; background: #27ae60; color: white; border: none; border-radius: 4px; font-size: 18px; font-weight: bold; cursor: pointer; transition: background 0.3s; margin-top: 10px; }
#seo-calc-btn:hover { background: #219150; }
#seo-result-box { background: #f8f9fa; border: 1px solid #e9ecef; border-radius: 6px; padding: 20px; text-align: center; margin-top: 20px; }
.seo-result-item { margin-bottom: 15px; padding-bottom: 15px; border-bottom: 1px solid #ddd; }
.seo-result-item:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.seo-result-label { display: block; font-size: 14px; color: #666; margin-bottom: 5px; }
.seo-result-value { display: block; font-size: 28px; font-weight: 800; color: #2c3e50; }
.seo-result-sub { font-size: 18px; color: #555; }
#seo-calc-content { padding: 25px; background: #fff; border-top: 1px solid #eee; line-height: 1.6; color: #444; }
#seo-calc-content h3 { color: #2c3e50; margin-top: 25px; margin-bottom: 10px; font-size: 20px; }
#seo-calc-content p { margin-bottom: 15px; font-size: 16px; }
#seo-calc-content ul { padding-left: 20px; margin-bottom: 15px; }
#seo-calc-content li { margin-bottom: 8px; }
@media (max-width: 600px) {
#seo-calc-body { flex-direction: column; gap: 15px; }
}
function calculateMortgage() {
// Get Input Values
var price = parseFloat(document.getElementById("homePrice").value);
var down = parseFloat(document.getElementById("downPayment").value);
var rate = parseFloat(document.getElementById("interestRate").value);
var years = parseFloat(document.getElementById("loanTerm").value);
var tax = parseFloat(document.getElementById("propertyTax").value);
var insurance = parseFloat(document.getElementById("homeInsurance").value);
var hoa = parseFloat(document.getElementById("hoaFees").value);
// Validation
if (isNaN(price) || isNaN(down) || isNaN(rate) || isNaN(years)) {
alert("Please enter valid numbers for Price, Down Payment, Rate, and Term.");
return;
}
// Defaults for optional fields
if (isNaN(tax)) tax = 0;
if (isNaN(insurance)) insurance = 0;
if (isNaN(hoa)) hoa = 0;
// Calculations
var principal = price – down;
var monthlyRate = rate / 100 / 12;
var numberOfPayments = years * 12;
var monthlyPrincipalInterest = 0;
if (rate === 0) {
monthlyPrincipalInterest = principal / numberOfPayments;
} else {
monthlyPrincipalInterest = principal * (monthlyRate * Math.pow(1 + monthlyRate, numberOfPayments)) / (Math.pow(1 + monthlyRate, numberOfPayments) – 1);
}
var monthlyTax = tax / 12;
var monthlyInsurance = insurance / 12;
var totalMonthlyPayment = monthlyPrincipalInterest + monthlyTax + monthlyInsurance + hoa;
var totalRepayment = monthlyPrincipalInterest * numberOfPayments;
var totalInterest = totalRepayment – principal;
var totalCost = totalRepayment + down; // Total money out of pocket for the home purchase + financing
// Formatting currency
var formatter = new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD',
});
// Display Results
document.getElementById("resultMonthly").innerHTML = formatter.format(totalMonthlyPayment);
document.getElementById("resultPrincipal").innerHTML = formatter.format(monthlyPrincipalInterest);
document.getElementById("resultTotalInterest").innerHTML = formatter.format(totalInterest);
document.getElementById("resultTotalCost").innerHTML = formatter.format(totalCost);
}
// Run calculation on load with default values
window.onload = function() {
calculateMortgage();
};
How to Calculate Your Mortgage Payment
Understanding your monthly mortgage payment is the first step in determining how much home you can afford. This calculator uses the standard PITI formula (Principal, Interest, Taxes, and Insurance) to give you an accurate estimate of your monthly housing costs.
The Components of Your Payment (PITI)
- Principal: The portion of your payment that goes toward paying down the loan balance (the $350,000 house price minus your down payment).
- Interest: The cost of borrowing money from the lender. In the early years of a mortgage, a large percentage of your payment goes toward interest.
- Taxes: Property taxes assessed by your local government, typically paid annually but often collected monthly by your lender in an escrow account.
- Insurance: Homeowners insurance protects your property against damage. Like taxes, this is often bundled into your monthly payment.
Why the Down Payment Matters
Your down payment significantly impacts your monthly obligations. A larger down payment reduces the principal loan amount, which lowers your monthly Principal & Interest payment. Additionally, if you put down less than 20% of the home's value, you may be required to pay Private Mortgage Insurance (PMI), which would increase your monthly costs further.
How Interest Rates Affect Affordability
Even a small change in interest rates can drastically change the total cost of your loan. For example, on a $300,000 loan, the difference between a 6% and a 7% interest rate can add hundreds of dollars to your monthly payment and tens of thousands of dollars to the total interest paid over 30 years. Use this calculator to compare scenarios and find a budget that works for you.