Validate values with a specific number of digits
The following regular expression will allow to validate values with a specific number of values.
The particular example below allows to validate 6-digit values:
^([0-9]{6}$
This way, only digits from 0 to 9 will be accepted with a total of 6 digits, neither more nor less.
You can change the value {6} for the number of digits that will be required for the field. For example, if you need to validate 9-digit values, the regular expression will be as follows:
^[0-9]{9}$
Iniciar sesión para dejar un comentario.