The goal of this script is to insert thousand separators into number string as the user types the number to avoid confusion when numbers get longer, like up to billion. I have achieved this on internet explorer but i'm strugling to get it crossplatform compatible.
123456789 as example string:
on IE and Firefox i get 123,456,789 as expected.
on opera however, i get 1,234 as expected.. then the cursor lags one character so when pressing 5, i get 12,354, then 123,564, then 1,235,674.. adding the comma by script doesnt move the cursor while the string gets one character longer.
My code retrieves textarea value with new char added to it, removes commas by regexp and then adds commas back to their right places in next sweep. Tthe value is then placed back to the source textarea.
Is there a way around this problem or maybe even a dirty hack to make it work? i'm pretty novice with javascripting still
123456789 as example string:
on IE and Firefox i get 123,456,789 as expected.
on opera however, i get 1,234 as expected.. then the cursor lags one character so when pressing 5, i get 12,354, then 123,564, then 1,235,674.. adding the comma by script doesnt move the cursor while the string gets one character longer.
My code retrieves textarea value with new char added to it, removes commas by regexp and then adds commas back to their right places in next sweep. Tthe value is then placed back to the source textarea.
Is there a way around this problem or maybe even a dirty hack to make it work? i'm pretty novice with javascripting still