victorjonsson / jQuery-Form-Validator

[DISCONTINUED] jQuery plugin that makes it easy to validate user input while keeping your HTML markup clean from javascript code.
972 stars 476 forks source link

Error validating numbers in scientific notation #639

Open nancystodd opened 7 years ago

nancystodd commented 7 years ago

HTML5 text inputs display numbers that are too small or too large in scientific notation. When using the number validator and allowing floats, the input values displayed in scientific notation report an error for otherwise valid numbers. For example, if I have a value of o.ooooooo1, it displays as 1E-8 and the validation displays an error. Because we have many values that are very small or very large, we do not want to simply disallow the use of scientific notation in our inputs. Is there a workaround for this problem?

victorjonsson commented 7 years ago

Well, in that case I would try using a custom regexp instead (here they're having a discussion about that particular subject)

Try it out here: (allowing both floats and scientific notations) http://jsbin.com/bidakevexi/edit?html,output