Field to 2 digits

Hello,

I would like to limit a Decimal field to 2 digits (the user can only enter up to 99. I tried that but it doesn’t work.

<field name="number" widget="Decimal" required="true" x-scale="2" x-precision="2"
          colSpan="3" />

why ?

image

You can use max=« 99 »

<field name="number" widget="Decimal" required="true" max="99" colSpan="3" />

OR
set x-precision=« 4 » because it is use to specified length of digits

<field name="number" widget="Decimal" required="true" x-scale="2" x-precision="4" colSpan="3" />

yes but what I want is that the user cannot exceed one unit and ten. From 0 to 99 in fact. So how do I do? please.

you can use min and max for set the range that you want

it doesn’t work, I can enter more than 99… see:

image

what I’m looking for is max: 99 only.

I put what you told me :

<field name="number" widget="Decimal" required="true" min="1" max="10" colSpan="3" />

Hello,
Here see the red line on the field. it is showing an invalid value for this field. Users can enter more than 99 but can’t save the form.
<field name="number" widget="Decimal" required="true" min="0" max="99" colSpan="3" />

Hello,

yes but I would just like to block this entry to 2 digits only, as we could do in Javascript.
how can I do?

I’m starting with axelor but I think if you change: type=« integer » min=« 2 » max=« 99 » and remove the widget.

1 « J'aime »

Ce sujet a été automatiquement fermé après 30 jours. Aucune réponse n’est permise dorénavant.