Hsbc Interest Rate Calculator
.dti-calculator-widget {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
max-width: 800px;
margin: 0 auto;
background: #ffffff;
border: 1px solid #e2e8f0;
border-radius: 8px;
box-shadow: 0 4px 6px rgba(0,0,0,0.05);
padding: 30px;
color: #2d3748;
}
.dti-calculator-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 20px;
}
@media (max-width: 768px) {
.dti-calculator-grid {
grid-template-columns: 1fr;
}
}
.dti-input-group {
margin-bottom: 15px;
}
.dti-input-group label {
display: block;
font-weight: 600;
margin-bottom: 8px;
font-size: 0.95rem;
color: #4a5568;
}
.dti-input-group input {
width: 100%;
padding: 12px;
border: 2px solid #cbd5e0;
border-radius: 6px;
font-size: 1rem;
transition: border-color 0.2s;
box-sizing: border-box;
}
.dti-input-group input:focus {
border-color: #3182ce;
outline: none;
}
.dti-btn {
background-color: #3182ce;
color: white;
border: none;
padding: 15px 30px;
font-size: 1.1rem;
font-weight: bold;
border-radius: 6px;
cursor: pointer;
width: 100%;
margin-top: 20px;
transition: background-color 0.2s;
}
.dti-btn:hover {
background-color: #2c5282;
}
.dti-results {
margin-top: 30px;
padding: 20px;
background-color: #f7fafc;
border-radius: 8px;
display: none;
border-left: 5px solid #3182ce;
}
.dti-result-row {
display: flex;
justify-content: space-between;
margin-bottom: 10px;
font-size: 1.1rem;
}
.dti-highlight {
font-size: 2rem;
font-weight: bold;
color: #2d3748;
margin: 15px 0;
}
.dti-badge {
display: inline-block;
padding: 5px 10px;
border-radius: 4px;
font-weight: bold;
color: white;
font-size: 0.9rem;
}
.seo-content {
margin-top: 50px;
line-height: 1.6;
color: #4a5568;
}
.seo-content h2 {
color: #2d3748;
margin-top: 30px;
}
function calculateDTI() {
// Get values from inputs
var income = parseFloat(document.getElementById('monthlyGrossIncome').value);
var housing = parseFloat(document.getElementById('rentMortgage').value);
var cars = parseFloat(document.getElementById('carLoans').value);
var cards = parseFloat(document.getElementById('creditCards').value);
var students = parseFloat(document.getElementById('studentLoans').value);
var other = parseFloat(document.getElementById('otherDebt').value);
// Validate Income
if (isNaN(income) || income <= 0) {
alert("Please enter a valid Gross Monthly Income greater than zero.");
return;
}
// Handle NaN for empty debt fields (treat as 0)
if (isNaN(housing)) housing = 0;
if (isNaN(cars)) cars = 0;
if (isNaN(cards)) cards = 0;
if (isNaN(students)) students = 0;
if (isNaN(other)) other = 0;
// Calculate Totals
var totalDebt = housing + cars + cards + students + other;
var dtiRatio = (totalDebt / income) * 100;
// Display Results Div
var resultDiv = document.getElementById('dtiResult');
resultDiv.style.display = 'block';
// Update Text Content
document.getElementById('displayTotalDebt').innerText = '$' + totalDebt.toLocaleString('en-US', {minimumFractionDigits: 2, maximumFractionDigits: 2});
document.getElementById('displayDTI').innerText = dtiRatio.toFixed(2) + '%';
// Status Logic
var statusDiv = document.getElementById('dtiStatus');
var explanationP = document.getElementById('dtiExplanation');
var statusBadge = '';
var explanation = '';
var color = '';
if (dtiRatio <= 35) {
color = '#48bb78'; // Green
statusBadge = 'Excellent Health';
explanation = 'Your DTI is below 35%. This is considered excellent by lenders. You likely have plenty of disposable income and are a strong candidate for new credit.';
resultDiv.style.borderLeftColor = color;
} else if (dtiRatio > 35 && dtiRatio <= 43) {
color = '#ecc94b'; // Yellow/Orange
statusBadge = 'Manageable';
explanation = 'Your DTI is between 36% and 43%. This is acceptable for most mortgages (specifically Qualified Mortgages), but you should be cautious about taking on more debt.';
resultDiv.style.borderLeftColor = color;
} else if (dtiRatio > 43 && dtiRatio < 50) {
color = '#ed8936'; // Orange
statusBadge = 'Caution Needed';
explanation = 'Your DTI is above the standard 43% threshold used by many mortgage lenders. You may find it difficult to qualify for loans with favorable terms.';
resultDiv.style.borderLeftColor = color;
} else {
color = '#f56565'; // Red
statusBadge = 'High Risk';
explanation = 'Your DTI is 50% or higher. This indicates you may be over-leveraged. Financial experts recommend reducing debt aggressively to improve your financial flexibility.';
resultDiv.style.borderLeftColor = color;
}
statusDiv.innerHTML = statusBadge;
explanationP.innerText = explanation;
document.getElementById('displayDTI').style.color = color;
}