How to create a form field that accepts a negative number?

Hi,

Newbie here :slight_smile:

Apparently the number type only accepts positive numbers.
How can I create a field that accepts negative numbers?

(It would also be nice if the number field could have a max and a min value associated with it.)

Thanks

Just after I typed the question, I found the answer:

longitude:
    label: Longitude
    step: .0000001
    validate:
        min: -100
        max: 100
        - number

It does accept negative numbers, but you need to tell it to do so (the default minimum is 0):

fields:
  price:
    label: Price
    type: number
    min: -10
    max: 10

I will add this information to the documentation. Thanks!

Edit: Your code should also work, but the β€œofficial” solution is the one I posted. When just using the validation, the attribute on the input field won’t get set, which means that the up/down buttons in the browser won’t work.

1 Like

Great Lukas, thank you :slightly_smiling: