[BUG] - Form Allows Submission with Decimal in Number Input
HeroUI Version
2.4.17
Describe the bug
When the number input contains an invalid value, such as a decimal number, the form still allows submission instead of blocking it as expected.
Your Example Website or App
https://github.com/znadir/bug-number-input
Steps to Reproduce the Bug or Issue
- Enter a decimal number in the input
- Submit the form by clicking on the button. do not press enter
- Watch the form being submitted even when there is an error
Expected behavior
The number input allows decimal values. The form should not be submitted when clicking on submit button if the input contains a decimal.
Screenshots or Videos
Operating System Version
Windows
Browser
Firefox
Just took a deeper look. I won't suggest to use Input with number type since Input is using text field hook which does not handle numeric case well. For your case, any reason you are not using NumberInput? If the numeric input requires whole number, you can do the following with NumberInput.
<NumberInput label='Enter a number' formatOptions={{
maximumFractionDigits: 0
}} />
see https://www.heroui.com/docs/components/number-input
I didn't know about it thanks. That would still be nice to get the issue fixed
@wingkwong I think this can be closed right..?
@jassBawa I'll update the typing a bit. Ideally we would like to separate Input and NumberInput.