From 1cc33287293cef8b8031fbfb1c47bbac475def7e Mon Sep 17 00:00:00 2001 From: leigh-mil Date: Wed, 13 Feb 2019 10:17:44 -0500 Subject: [PATCH] Move NaN/empty string check to formatDollars --- js/components/text_input.js | 3 --- js/lib/dollars.js | 4 ++++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/js/components/text_input.js b/js/components/text_input.js index 0f99f899..506274a6 100644 --- a/js/components/text_input.js +++ b/js/components/text_input.js @@ -85,9 +85,6 @@ export default { }, onBlur: function(e) { - if (this.validation === 'dollars' && this.value === '$NaN') { - this.value = this.initialValue - } this._checkIfValid({ value: e.target.value, invalidate: true }) }, diff --git a/js/lib/dollars.js b/js/lib/dollars.js index 5ef65828..2085a0b5 100644 --- a/js/lib/dollars.js +++ b/js/lib/dollars.js @@ -5,6 +5,10 @@ export const formatDollars = (value, cents = true) => { currency: 'USD', }) } else if (typeof value === 'string') { + if (value === '') { + return value + } + return parseFloat(value).toLocaleString('us-US', { style: 'currency', currency: 'USD',