Skip to content

HTML5 validation not playing nicely with decimal numbers #4429

Closed

Description

@robinsowell

So- create a number field, set the type to decimal. Make a decimal. html 5 validation will object.

If the type = number? It's just not liking it.

Screenshot 2024-08-19 at 6 00 27 PM

Weirdly- a text field set to either number OR decimal does just fine with a decimal, but that's because the type in those cases is still text.

Screenshot 2024-08-19 at 5 39 35 PM

And I think we need to clarify in the docs the difference between a number field and a decimal field- for both text and decimal. But in a text field, it saves decimals ok, but drops the trailing zero if there is one.

Also note- if you switch back and forth between text and number types, the db doesn't always change. So don't test that way.

Activity

  1. added
    Bug: AcceptedBug has been confirmed, is reproducible, and ready to work on.
    on Aug 19, 2024
  2. intoeetive commented on Aug 24, 2024

    @intoeetive
    Contributor

    So technically this is correct - as the step is not set, the HTML Number input defaults step to 1 : https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number#step

    However it makes a sense if I switch the field type to "decimal" that I want some decimals. I'm submitting a PR that's setting default 2 digits after period if step is empty but the type is decimal

    The difference with the text field as it's using text HTML input

  3. added a commit that references this issue on Aug 24, 2024
    64593b9
  4. robinsowell commented on Aug 26, 2024

    @robinsowell
    ContributorAuthor

    Man- I totally missed that the 'step' was in play! I agree- I'd still expect it to allow decimals regardless, but I should have spotted that!

  5. added a commit that references this issue on Jun 16, 2025
    bfce0fe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug: AcceptedBug has been confirmed, is reproducible, and ready to work on.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions