Calculator Home Loan Mortgage Rate Calculator

Home Loan Mortgage Rate Calculator

function calculateMortgage() { const loanAmount = parseFloat(document.getElementById(‘loanAmount’).value); const interestRate = parseFloat(document.getElementById(‘interestRate’).value) / 100 / 12; const loanTerm = parseInt(document.getElementById(‘loanTerm’).value) * 12; if (isNaN(loanAmount) || isNaN(interestRate) || isNaN(loanTerm) || loanAmount <= 0 || interestRate <= 0 || loanTerm <= 0) { alert('Please enter valid values for all fields.'); return; } const monthlyPayment = loanAmount * interestRate / (1 – Math.pow(1 + interestRate, -loanTerm)); document.getElementById('monthlyPayment').value = monthlyPayment.toFixed(2); } function resetForm() { document.getElementById('homeLoanCalculatorForm').reset(); document.getElementById('monthlyPayment').value = ''; }

Leave a Reply

Your email address will not be published. Required fields are marked *