Is there any validation for integers where user can write only exact length of integer.
There is [Range] but that works only for range of value.
There is also [MaxLength] and [MinLength] for string but is there something like that for integers.
I need property that has type int but which allows to enter exactly 11 numbers.
I think one option is [Range(10000000000, 99999999999)], but that is awful.
2
Answers
Change the type to a string and use a simple Regex of
^d{11}$
. Otherwise you could build your own validator.you can use a textbox which can just typed numbers
in jquery side you can write
in cshtml side you can write like this
max length is 10 because max int value is 2,147,483,647