function calculateDTI() {
// 1. Get Inputs using var
var annualIncome = parseFloat(document.getElementById('annualIncome').value);
var monthlyRent = parseFloat(document.getElementById('monthlyRent').value);
var carLoans = parseFloat(document.getElementById('carLoans').value);
var studentLoans = parseFloat(document.getElementById('studentLoans').value);
var creditCards = parseFloat(document.getElementById('creditCards').value);
var otherDebt = parseFloat(document.getElementById('otherDebt').value);
// 2. Validate Income
if (isNaN(annualIncome) || annualIncome <= 0) {
alert("Please enter a valid Annual Gross Income greater than zero.");
return;
}
// 3. Handle empty debt fields as 0
if (isNaN(monthlyRent)) monthlyRent = 0;
if (isNaN(carLoans)) carLoans = 0;
if (isNaN(studentLoans)) studentLoans = 0;
if (isNaN(creditCards)) creditCards = 0;
if (isNaN(otherDebt)) otherDebt = 0;
// 4. Calculate Monthly Income and Total Monthly Debt
var monthlyIncome = annualIncome / 12;
var totalMonthlyDebt = monthlyRent + carLoans + studentLoans + creditCards + otherDebt;
// 5. Calculate Ratio
var dtiRatio = (totalMonthlyDebt / monthlyIncome) * 100;
// 6. Determine Status and Styling
var resultBox = document.getElementById('dtiResult');
var percentDisplay = document.getElementById('dtiPercent');
var statusDisplay = document.getElementById('dtiStatus');
var messageDisplay = document.getElementById('dtiMessage');
var statusText = "";
var statusColor = "";
var messageText = "";
var borderColor = "";
if (dtiRatio <= 35) {
statusText = "Excellent";
statusColor = "#27ae60"; // Green
borderColor = "#27ae60";
messageText = "Lenders view you as a low-risk borrower. You are in a great position to get approved for a mortgage or loan with favorable interest rates.";
} else if (dtiRatio <= 43) {
statusText = "Good / Manageable";
statusColor = "#f39c12"; // Orange
borderColor = "#f39c12";
messageText = "You are within the standard limit (43%) for most Qualified Mortgages. You should still be able to get approved, though some lenders may inspect your finances more closely.";
} else if (dtiRatio <= 49) {
statusText = "High Risk";
statusColor = "#e67e22"; // Dark Orange
borderColor = "#e67e22";
messageText = "You are above the 43% threshold favored by most mortgage lenders. You may struggle to find a loan, or you may be required to pay a higher interest rate.";
} else {
statusText = "Critical";
statusColor = "#c0392b"; // Red
borderColor = "#c0392b";
messageText = "Your debt payments consume more than half of your gross income. Lenders are unlikely to approve new loans until you reduce your debt load.";
}
// 7. Update DOM
percentDisplay.innerHTML = dtiRatio.toFixed(2) + "%";
statusDisplay.innerHTML = statusText;
statusDisplay.style.color = statusColor;
messageDisplay.innerHTML = messageText;
resultBox.style.display = "block";
resultBox.style.borderLeftColor = borderColor;
}
Understanding Your Debt-to-Income (DTI) Ratio
Your Debt-to-Income (DTI) ratio is one of the most critical metrics lenders use to assess your financial health. Unlike your credit score, which measures your history of paying bills, your DTI measures your capacity to repay new debt based on your current income.
The Formula:
DTI = (Total Monthly Debt Payments / Gross Monthly Income) x 100
Why is the 43% Mark Important?
In the mortgage industry, 43% is widely considered the maximum DTI ratio a borrower can have and still get a Qualified Mortgage. While some lenders (such as FHA or VA loans) may allow ratios up to 50% with compensating factors (like large cash reserves), keeping your DTI below 43% drastically increases your chances of approval.
Front-End vs. Back-End Ratio
Lenders often look at two different types of DTI ratios:
Front-End Ratio: This only includes your housing costs (principal, interest, taxes, insurance, and HOA fees) divided by your income. Ideally, this should be under 28%.
Back-End Ratio: This is the number calculated above. It includes housing costs plus all other monthly debt obligations like car loans, student loans, and credit cards. Ideally, this should be under 36% for the best rates.
What is Included in DTI?
When using the calculator above, ensure you include:
Minimum monthly credit card payments (not the total balance).
Auto loan and lease payments.
Student loan payments.
Alimony or child support payments.
Personal loan repayments.
Note: You generally do not need to include utilities, grocery bills, or phone bills in your DTI calculation, as these are considered living expenses rather than debt obligations.
How to Lower Your DTI
If your ratio is in the "High Risk" zone, consider these strategies before applying for a major loan:
Pay off small balances: Eliminate credit card debts or small loans entirely to remove that monthly obligation from the calculation.
Increase your income: Taking on a side gig or asking for a raise increases the denominator in the formula, lowering your percentage.
Refinance high-interest debt: If you can lower your monthly payment through refinancing (without extending the term too long), you can improve your DTI immediately.