autoNumeric: The `decimalCharacterAlternative` character is not translated to the `decimalCharacter` on paste
Expected behavior
When pasting a number with the alternate decimal character, I expect that it be treated the same as the primary decimal character. I.e. if decimalCharacterAlternative is & (ampersand), when pasting 123&45, I expect to see 123.45 in the input field.
Actual behavior
The ampersand is ignored and the number is treated as an integer. I.e. when pasting 123&45 the field is set to 12345.00. The behavior is the same regardless of what character is used as alternative.
Steps to reproduce the problem
- Using autoNumeric 2.0.10 and the Chrome version 56 on MacOS Sierra, and also Safari 10.0.3.
- I used the options
{
decimalCharacterAlternative: '&'
}
- Initialized my AutoNumeric object with the call
$('input').autoNumeric('init', {
decimalCharacterAlternative: '&',
});
- I copy “123&45” to the clipboard and paste it into the field. I get 12345,00.
Link to live example
About this issue
- Original URL
- State: open
- Created 7 years ago
- Comments: 20 (7 by maintainers)
Does somebody know how to fix the issue “45,34 -> 4534.00” without modifying the autonumeric code? Maybe there is a callback function where I can write my own custom logic after paste? Is there any workaround?
In my country people copy values from Excel (to the web app). These values can be in the following format “3 422 234,00” -Only spaces as group delimeters. Decimal delimeter can be “,” or “.” In my case I dont care about hypothetical values, such as 1,234,567.89
Just want to share my cross-browser solution (not too clean code, but it works. You could refine it according to your own taste).
SetupPasteNumberReformatter function: