Number field type

Hi,

Is there any “number” field type ?

Do I have to use a “text” type with a custom pattern like “[0-9]+(.[0-9]+)?” to simulate such type ? In that case the admin isn’t providing a suitable UI for numbers (no arrows or shortcuts to increment/decrement…).

I don’t see a “number” type in the docs. Did I miss something ?

Hi,

use the text type and add this to the field options

{
  "type": "number"
}
1 Like

Amazing, thanks !

Is there a min/max option or other number-related ones, and are they documented somewhere (source included) ?

as far as I know you can set all attributes that you could also set on an html input.

so

{
  "type": "number",
  "min" : 0,
  "max" : 10
}

should do the trick

no guarantee!

That’s what I thought too but it doesn’t !

Humm it should work, the textfield accepts the following attributes:

['maxlength', 'minlength', 'step', 'placeholder', 'pattern', 'size', 'min', 'max']

You can also pass a regex pattern in the field and do the validation using html5:

for example a max between 0 and 5000

(5000|([1-4]?[0-9]?[0-9]?[0-9]?))

2 Likes

Hi,

I tried again, but no success.

{
  "type": "number",
  "min": 0
}

(Version 0.8.3)

note that min and max are html5 input-field attributes - are you perhaps using a browser that does not support the min and max attrib on inputs?

Hi, I’m using Chrome / Version 70.0.3538.77

Use the value inside "":

{
  "type": "number",
  "min": "0",
  "max": "15"
}

image

1 Like

Ha, well seen, thanks !