Number Validation Rule

Type number fields help in simplifying your work when building the user interface and logic for entering numbers into a form. When creating a number input with the number type of validation rule, you get automatic validation that the entered text is actually a number and not a text.


Minimum and Maximum values

Using the 'min' and 'max' attributes, you can specify a Minimum and Maximum value that the field can have. For example, setting a minimum of 5, and a maximum of 50, you'll notice that the up and down step buttons will not allow you to go below 5 or above 50. You can still manually enter a number outside these bounds, but it will be invalidated.


Controlling step size

The default increment/decrement amount for each step is 1. You can change this by providing a step attribute in the field configuration. This should be set based on your currently configured minimum and maximum allowed values.


Allowing decimal values

The number type of input have set the step size to 1 by default — if you are trying to enter a number with a decimal, such as '1.0', this will invalidate the field. If you want to enter a value that requires decimals, you'll need to properly set this in the step value (e.g. step="0.1" to allow one decimal).


9 persons found this article helpful.

Was this article helpful?

Yes No
Sorry about that