function calculateDTI() {
// 1. Retrieve inputs using var, ensuring we handle empty or non-numeric inputs
var incomeInput = document.getElementById('dti-gross-income').value;
var mortgageInput = document.getElementById('dti-rent-mortgage').value;
var autoInput = document.getElementById('dti-auto-loans').value;
var studentInput = document.getElementById('dti-student-loans').value;
var cardsInput = document.getElementById('dti-credit-cards').value;
var otherInput = document.getElementById('dti-other-debt').value;
// 2. Parse inputs to floats, defaulting to 0 if NaN (empty or invalid)
var grossIncome = parseFloat(incomeInput) || 0;
var mortgage = parseFloat(mortgageInput) || 0;
var auto = parseFloat(autoInput) || 0;
var student = parseFloat(studentInput) || 0;
var cards = parseFloat(cardsInput) || 0;
var other = parseFloat(otherInput) || 0;
var resultDiv = document.getElementById('dti-result');
var totalDebtDisplay = document.getElementById('dti-total-debt-display');
var percentValueDisplay = document.getElementById('dti-percent-value');
var statusMessageDisplay = document.getElementById('dti-status-message');
// 3. Validate Income to prevent division by zero
if (grossIncome <= 0) {
alert("Please enter a Gross Monthly Income greater than zero to calculate DTI.");
resultDiv.style.display = "none";
return;
}
// 4. Calculate Total Monthly Debt
var totalMonthlyDebt = mortgage + auto + student + cards + other;
// 5. Calculate DTI Percentage formula: (Total Debt / Gross Income) * 100
var dtiRatio = (totalMonthlyDebt / grossIncome) * 100;
// 6. Determine status message and styling class based on standard lender guidelines
var statusText = "";
var statusClass = "";
if (dtiRatio = 36 && dtiRatio <= 43) {
statusText = "Manageable: You may still qualify for loans, but lenders will look closely.";
statusClass = "status-warning";
} else {
statusText = "High Risk: You may face difficulty qualifying for new credit or mortgages.";
statusClass = "status-danger";
}
// 7. Update the HTML output elements
// Format currency display
totalDebtDisplay.innerText = "$" + totalMonthlyDebt.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
// Format percentage display
percentValueDisplay.innerText = dtiRatio.toFixed(1) + "%";
// Update status message and styling
statusMessageDisplay.innerText = statusText;
statusMessageDisplay.className = "dti-result-status " + statusClass;
// Show the result container
resultDiv.style.display = "block";
}
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 and ability to repay borrowed money. It is a percentage that represents the portion of your gross monthly income that goes toward paying your monthly debt obligations.
Unlike your credit score, which measures your history of repaying debt, your DTI ratio measures your capacity to take on new debt. A lower ratio suggests that you have a good balance between debt and income, making you a less risky borrower in the eyes of mortgage lenders, auto financiers, and credit card issuers.
How DTI is Calculated
The calculation for your DTI ratio is relatively straightforward. It is your total recurring monthly debt payments divided by your gross monthly income (your income before taxes and other deductions).
What is included in "Total Monthly Debt Payments"?
Rent or mortgage payments (including property taxes and insurance if escrowed).
Car loan or lease payments.
Student loan required minimum payments.
Credit card required minimum payments.
Other debts like personal loans, child support, or alimony.
Note: Expenses like groceries, utilities, gas, and entertainment are typically NOT included in the DTI calculation.
What is a "Good" DTI Ratio?
While lender requirements vary depending on the loan type and current economic conditions, general guidelines exist regarding what constitutes a healthy DTI ratio.
For Mortgage Lenders
Mortgage lenders often use two different ratios: the "front-end ratio" (housing costs only divided by income) and the "back-end ratio" (total debt divided by income, which is what this calculator computes).
35% or less: Generally considered excellent. You likely have manageable debt levels relative to your income.
36% to 43%: This is often the "sweet spot" for qualification. Many conventional mortgages prefer a back-end DTI no higher than 43%, although some loan programs (like FHA) may allow higher ratios with compensating factors.
44% to 50%: Getting approved becomes more difficult. Lenders may require higher credit scores, larger down payments, or significant cash reserves.
Over 50%: It is very difficult to qualify for most standard mortgages, as lenders view this as high risk for default.
Example Calculation
Let's look at a realistic example. Suppose Jane earns a gross salary of $5,000 per month. Her monthly debt obligations are:
Rent: $1,400
Car Payment: $400
Student Loan: $300
Credit Card Minimums: $150
Her total monthly debt is $1,400 + $400 + $300 + $150 = $2,250.
To find her DTI, she divides her total debt by her gross income: $2,250 ÷ $5,000 = 0.45.
Multiply by 100 to get the percentage: 45%. In this scenario, Jane's DTI is on the higher end, and she might face challenges qualifying for a new mortgage without reducing her debt or increasing her income first.