KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I found i little snipet on internet, about PMT calculate. function PMT(i, n, p) { return i * p * Math.pow((1 + i), n) / (1 - Math.pow((1 + i), n)); } function CalculatePMTFromForm(idLoanAmount, idAnnualInterestRate, idMonths, idResult) { var i = jQuery('#' + idAnnualInterestRate).val() / 1200; var n = jQuery('#' + idMonths).val(); var p = jQuery('#' + idLoanAmount).val(); var pmt = PMT(i, n, -p); jQuery('#' + idResult).val(pmt.toFixed(2)); } function performCalc() { CalculatePMTFromForm('LoanAmount', 'InterestRate', 'Months', 'Payment'); } jQuery(document).ready(function() { performCalc(); jQuery('.calc').keyup(performCalc); }); When the page is load, in the result input box I see "NaN" , and when i tpye some irrelevant number then "-Infinity" msg appear. I search to "NaN" in files and i found in jquery.js, but after I modify, nothing change. And I can't find Infinity How can I change this messages? Edit Calling code:- function performCalc() { CalculatePMTFromForm('LoanAmount', 'InterestRate', 'Months', 'Payment'); } jQuery(document).ready(function() { performCalc(); jQuery('.calc').keyup(performCalc); }); This is worked for me: if(pmt>0 && pmt<Number.MAX_VALUE) {jQuery('#' + idResult).val(pmt.toFixed(2));}
Tags (comma-separated)
Save Edits
Cancel