Move NaN/empty string check to formatDollars

This commit is contained in:
leigh-mil 2019-02-13 10:17:44 -05:00
parent bf68ba6621
commit 1cc3328729
2 changed files with 4 additions and 3 deletions

View File

@ -85,9 +85,6 @@ export default {
}, },
onBlur: function(e) { onBlur: function(e) {
if (this.validation === 'dollars' && this.value === '$NaN') {
this.value = this.initialValue
}
this._checkIfValid({ value: e.target.value, invalidate: true }) this._checkIfValid({ value: e.target.value, invalidate: true })
}, },

View File

@ -5,6 +5,10 @@ export const formatDollars = (value, cents = true) => {
currency: 'USD', currency: 'USD',
}) })
} else if (typeof value === 'string') { } else if (typeof value === 'string') {
if (value === '') {
return value
}
return parseFloat(value).toLocaleString('us-US', { return parseFloat(value).toLocaleString('us-US', {
style: 'currency', style: 'currency',
currency: 'USD', currency: 'USD',