Skip to content
Advertisement

Allow input type number only a number/float between 0-1

I want to have an input number that allows any float between 0-1 including both whole numbers. But it’s proving quite tricky just getting the backspace to actually delete a numbers as it comes as NaN

I got this:

JavaScript

Advertisement

Answer

You can use achieve your goal with adding some conditions to the addRate state, also using step prop of input element:

JavaScript

Edit vigorous-framework-x233g

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement