I need to format a currency entry field, to replace different formats users may enter, with a French Canadian style like this: 1 234,56 $ So far I have patched together the below: var x = Number(event.value).toFixed(2); event.value =
event.value = x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " ").replace(/\./g, ',') + " $"; It works if users enter these formats: 123.45 123,45 1234.56 1234,56 12345.56 12345,56 But users get an 'NaN' if these formats are entered: 1,234.56 1 234.56 1 234,56 12,345.67 12 345.67 Guessing I'm missing something for spaces or commas in the thousands separator.
... View more