I have an input where the user introduces a number, integer or float. I would like to know it the number is correct, for example, check that the input 2r
is not correct. My first approach was to use parseFloat
, but it does not complain about that:
parseFloat('2r') // returns 2
Actually, this is the expected behaviour according to the docs
How do you check that 2r
is wrong?