Calculation Steps:
No calculation yet.
function calculateEMI() {
let loanAmount = parseFloat(document.getElementById(“loanAmount”).value);
let annualRate = parseFloat(document.getElementById(“interestRate”).value);
let loanTenure = parseFloat(document.getElementById(“loanTenure”).value);
if (isNaN(loanAmount) || isNaN(annualRate) || isNaN(loanTenure) || loanAmount <= 0 || annualRate <= 0 || loanTenure <= 0) {
alert("Please enter valid positive values.");
return;
}
let monthlyRate = annualRate / 12 / 100;
let tenureMonths = loanTenure * 12;
let emi = (loanAmount * monthlyRate * Math.pow(1 + monthlyRate, tenureMonths)) / (Math.pow(1 + monthlyRate, tenureMonths) – 1);
document.getElementById("emiAmount").value = emi.toFixed(2);
let steps = `
Inputs:
Loan Amount: ₹${loanAmount}
Annual Interest Rate: ${annualRate}%
Loan Tenure: ${loanTenure} years
Formula:
EMI = (Loan Amount * Monthly Interest Rate * (1 + Monthly Interest Rate) ^ Tenure Months) / ((1 + Monthly Interest Rate) ^ Tenure Months – 1)
Calculated EMI: ₹${emi.toFixed(2)}
`;
document.getElementById(“steps-content”).innerHTML = steps;
document.getElementById(“emi-calculation-steps”).style.display = “block”;
}
function resetForm() {
document.getElementById(“loan-calculator-form”).reset();
document.getElementById(“emiAmount”).value = “”;
document.getElementById(“emi-calculation-steps”).style.display = “none”;
}