asckpit
November 11, 2018, 4:31pm
1
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 ?
artur
November 11, 2018, 8:26pm
2
Hi,
use the text
type and add this to the field options
{
"type": "number"
}
1 Like
asckpit
November 11, 2018, 9:36pm
3
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!
asckpit
November 11, 2018, 11:25pm
5
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
asckpit
November 12, 2018, 3:27pm
7
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?
asckpit
November 12, 2018, 6:59pm
9
Hi, I’m using Chrome / Version 70.0.3538.77
Use the value inside ""
:
{
"type": "number",
"min": "0",
"max": "15"
}
1 Like