number field renders a single line text box that takes numbers only.
your_age: label: Your Age type: number
The following properties are supported.
|min||the client-side minimum value, default |
|max||the client-side maximum value, default |
|step||the client-side step increment, default |
You may use the
max properties to constrain the input by minimum and maximum values. The following will only accept an input between 1 and 100.
your_age: label: Your Age type: number min: 1 max: 100
step property to control the increments that the number can be increased or decreased by, this value defaults to any.
your_age: label: Your Age type: number step: 10
# Server-side Validation
If you would like to validate this field server-side on save to ensure that it is numeric. When working with tailor fields, use the
your_age: label: Your Age type: number validation: numeric
When working with models, use the
$rules property on your model, like so.
public $rules = [ 'your_age' => 'numeric', ];
For more information on model validation, please visit the validation service article.