Unformatted value (or floatValue) within onChange
See original GitHub issueIs there a way to get the whole ChangeEvent
with the unformatted value (or float value)?
I’m using formik
and therefore need to use onChange
, because it needs the ChangeEvent
data to determine which field has changed.
The problem is, that onChange
’s event.target.value
contains the formatted value. But I need the unformatted value (or float value).
<NumberFormat
onChange={(event) => {
console.log(event); // I need this event
console.log(event.target.value); // This is the formatted value, I don't want
}}
onValueChange={(values) => {
console.log(values.value); // Here's the unformatted value, I want
console.log(values.floatValue); // Here's the float value, which is okay, too
}}
prefix="$"
/>
In other words: I need onChange
with the value provided by onValueChange
.
Is there any way to get this working?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:12
- Comments:24 (3 by maintainers)
Top Results From Across the Web
React-Number-Format pass value as float to validation
What I'm trying to do is to format an input with react-number-format but also to pass float value to validation and to submit....
Read more >Developers - Unformatted value (or floatValue) within onChange -
I'm using formik and therefore need to use onChange , because it needs the ChangeEvent data to determine which field has changed. The...
Read more >Formatted and Unformatted Input/Output functions in C with ...
printf() function is used in a C program to display any value like float, integer, character, string, etc on the console screen.
Read more >react-number-format - npm
Value to the number format. It can be a float number, or formatted string. If value is string representation of number (unformatted), isNumericString...
Read more >Default currency values in scripts
Methods such as getValue() and getCurrencyValue() return unformatted numbers as strings. To obtain the floating point value, ...
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
I think that majority of us have problems when upgrading to v4 when this was changed:
While
onChange
is triggered only at typing,onValueChange
is triggered at typing and at prop change event. This is crucial! What most of us need is pure value atonChange
listener and this is not possible anymore out of the box. I’ve tested it @rsilvamanayalle solution and it does work, but we are relying on thatonChangeValue
is called beforeonChange
which is bad.I don’t know if this a pretty solution, but it work well for me…