Excel - PMT - NaN and Infinity messages

Excel - PMT - NaN and Infinity messages

Hello!

I use this snipet, to calculate PMT.
     
  1.  
  2. function PMT(i, n, p) {
  3.  return i * p * Math.pow((1 + i), n) / (1 - Math.pow((1 + i), n));
  4.  }
  5.  function CalculatePMTFromForm(idLoanAmount, idAnnualInterestRate, idMonths, idResult) {
  6.  var i = jQuery('#' + idAnnualInterestRate).val() / 1200;
  7.  var n = jQuery('#' + idMonths).val();
  8.  var p = jQuery('#' + idLoanAmount).val();
  9.  var pmt = PMT(i, n, -p);
  10.   jQuery('#' + idResult).val(pmt.toFixed(2));
  11.   }
  12.   function performCalc() {
  13.   CalculatePMTFromForm('LoanAmount', 'InterestRate', 'Months', 'Payment');
  14.   }
  15.    jQuery(document).ready(function() { performCalc(); jQuery('.calc').keyup(performCalc); });
  16.  
  17.  The result shown in this input box:
  18.    <td><input id="Payment" size="11" type="text" value="" /></td>

If i delete the input box value or get negative value, or start the
value with 0, i get an error message in the result input box (NaN or
Infinity)

Could anyone help me to disable, or change this message text?

Thank you.