diff --git a/src/pages/iou/steps/IOUAmountPage.js b/src/pages/iou/steps/IOUAmountPage.js index 98112ff9d33d..1fa98e339b59 100755 --- a/src/pages/iou/steps/IOUAmountPage.js +++ b/src/pages/iou/steps/IOUAmountPage.js @@ -153,7 +153,13 @@ class IOUAmountPage extends React.Component { calculateAmountLength(amount) { const leadingZeroes = amount.match(/^0+/); const leadingZeroesLength = lodashGet(leadingZeroes, '[0].length', 0); - const absAmount = parseFloat((amount * 100).toFixed(2)).toString(); + const absAmount = parseFloat((this.stripCommaFromAmount(amount) * 100).toFixed(2)).toString(); + + // The following logic will prevent users from pasting an amount that is excessively long in length, + // which would result in the 'absAmount' value being expressed in scientific notation or becoming infinity. + if (/\D/.test(absAmount)) { + return CONST.IOU.AMOUNT_MAX_LENGTH + 1; + } /* Return the sum of leading zeroes length and absolute amount length(including fraction digits).