As you know there is a property called [StringLength] in model of mvc. I have a variable which is an int and I want to restrict it to maximum 4 characters. I need something like [IntLength]. Can you help me?
[Display(Name="Credit card number:")]
[RegularExpression(@"\d{4}")]
public int BookingCardNumberFirstFour { get; set; }
<%: Html.TextBoxFor(model => model.BookingCardNumberFirstFour, new {style="width:40px;"}) %>
You can use the range attribute.
if you want them to enter exactly 4 digits use the regular expression attribute.