Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decimal values not allowed when entering integer minimum and maximum for 'number' types #157

Open
ErikKoinberg opened this issue Feb 25, 2024 · 4 comments

Comments

@ErikKoinberg
Copy link

A possible solution could be to add a way to add the step html attribute into the form inputs, perhaps by specifying decimalPlaces for 'number' type fields.

@ErikKoinberg ErikKoinberg changed the title Decimal values not allowed when entering a integer minimum and maximum for 'number' types Decimal values not allowed when entering integer minimum and maximum for 'number' types Feb 25, 2024
@ErikKoinberg
Copy link
Author

ErikKoinberg commented Feb 25, 2024

A possible quick-fix that I can think of is to add something like this to the JS:
const jsonFormNumberInputs = document.querySelectorAll('input[type="number"][name*="rjf§"]'); jsonFormNumberInputs.forEach(function(input) { input.setAttribute('step', '0.01'); });
This uses the namings of the fields to add a step attribute to these. More specific querying could be used if different number fields need different step values.

@bhch
Copy link
Owner

bhch commented Feb 28, 2024

I can not reproduce this.

I tried the following schema and I can add a decimal value without problems.

{
  "type": "object",
  "properties": {
    "value": {
      "type": "number",
      "minimum": 1,
      "maximum": 10
    }
  }
}

@ErikKoinberg
Copy link
Author

How strange. What browser were you using? After getting rendered into html, I got an input element with min and max values and a number type. When trying to submit a decimal value between the limits it did not work. I am using Firefox.

@bhch
Copy link
Owner

bhch commented Mar 6, 2024

I'm also using Firefox (119).

Perhaps you could share reproducible code in a sample github repo?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants