I have a registration form and the user must enter the square footage of their house. I would like this value to be only an integer. Is there a way to validate this value using attributes asp.net mvc?
Realise this has already been answered, but Stefanvds' answer is uneccessarily complicated. Just use MVCs built in validation attributes:
[DisplayName("Square Feet")]
[Required(ErrorMessage = "Square Feet is Required")]
[Range(0, int.MaxValue, ErrorMessage = "Square Feet must be a positive number")]
public int SquareFeet { get; set; }