Excel PMT function in JS
<p>I found i little snipet on internet, about PMT calculate.</p>

<pre><code>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); });
</code></pre>

<p>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</p>

<p>How can I change this messages?</p>

<p><strong>Edit</strong></p>

<p>Calling code:-</p>

<pre><code>function performCalc() {
  CalculatePMTFromForm('LoanAmount', 'InterestRate', 'Months', 'Payment');
}

jQuery(document).ready(function() {
  performCalc(); jQuery('.calc').keyup(performCalc);
});
</code></pre>

<p>This is worked for me:</p>

<pre><code>if(pmt&gt;0 &amp;&amp; pmt&lt;Number.MAX_VALUE) {jQuery('#' + idResult).val(pmt.toFixed(2));}
</code></pre>
