The `decimalCharacterAlternative` character is not translated to the `decimalCharacter` on paste
See original GitHub issueExpected 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
Issue Analytics
- State:
- Created 6 years ago
- Comments:20 (7 by maintainers)
Top Results From Across the Web
autoNumeric won't allow decimal input from numeric keyboard ...
Use "decimalCharacterAlternative": "." which will work as alternative for your main decimal character when pressed. Here is more options.
Read more >autonumeric - UNPKG
n\t * - 'truncate' : autoNumeric will insert as many pasted numbers it can at ... tries to paste a single decimal character...
Read more >Easy Number and Currency Formatting Library - autoNumeric
/* Defines if the decimal character or decimal character alternative should be accepted when there is already a decimal character shown in the ......
Read more >Restrict copy, paste and special characters - OutSystems
ready function. - Reference your textbox runtime id. (this will be translated automaticly to the html id of the element). - Disable the...
Read more >char conversion when copy+paste into a text field — oracle-tech
various characters in the source text(word document) which are not translating well when copy+pasted. For example: The source text has a ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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: