Use the Range
Attribute.
Set minimum to 1 and maximum to int.MaxValue
[Range(1, int.MaxValue, ErrorMessage = "Value for {0} must be between {1} and {2}.")]
More Related Contents:
- How to change default validation error message in ASP.NET MVC?
- Validate object based on external factors (ie. data store uniqueness)
- Remote Validation in ASP.Net MVC 3: How to use AdditionalFields in Action Method
- MVC Model require true
- DataAnnotations validation (Regular Expression) in asp.net mvc 4 – razor view
- DateTime (date and hour) validation with Data Annotation
- DataAnnotations dynamically attaching attributes
- Validation does not work when I use Validator.TryValidateObject
- Why is DisplayFormat DataFormatString not working?
- Get [DisplayName] attribute of a property in strongly-typed way
- ASP.Net MVC DisplayFormat
- How to render an ASP.NET MVC view as a string?
- MVC5 – How to set “selectedValue” in DropDownListFor Html helper
- ASP.NET MVC Model vs ViewModel
- How do I redirect to the previous action in ASP.NET MVC?
- Implementing Profile Provider in ASP.NET MVC
- Redirect from asp.net web api post action
- Challenges with selecting values in ListBoxFor
- What is the right time for ViewData, ViewBag, Session, TempData
- Uploading Files into Database with ASP.NET MVC
- The ViewData item that has the key ‘MY KEY’ is of type ‘System.String’ but must be of type ‘IEnumerable’
- asp.net mvc decorate [Authorize()] with multiple enums
- Merge MyDbContext with IdentityDbContext
- How to return Json object from MVC controller to view
- MVC Razor view Intellisense broken in VS 2013/2015/2017
- Are ActionFilterAttributes reused across threads? How does that work?
- ASP.NET MVC How to specify which folder the View pages reside in?
- How can I disable client side and proxy caching in ASP.NET MVC?
- IIS Express — Getting SSL to Work
- Hiddenfor not getting correct value from view model