How to check validation for numbersonly in data annotations?
You can use the Range validator:
[Range(0, int.MaxValue, ErrorMessage="Numbers only, please")]
Or you can use Regex:
[RegularExpression(@"^\d+$", ErrorMessage="Numbers only, please")]
Hi,
Use this
[Range(0, int.MaxValue, ErrorMessage = "Please enter valid Number")] public int Total { get; set; }