I am new to MVC. I am trying to validate text box value for only integers.
Here is my property and data annotations that I have tried so far
[Required(ErrorMessage = @"Must Enter EOT Months")]
[RegularExpression("([0-9]+)", ErrorMessage = @"EOT Months ")]
[Range(0, int.MaxValue, ErrorMessage = @"EOT Months must be numeric and a whole number")]
public int PayoutEOTMths
{
get { return DisposalConstant.PayoutEOTMths; }
set { DisposalConstant.PayoutEOTMths = value; }
}
But whenever I am entering value such as 6.5. It is giving me default validation message that is
•The value '6.5' is not valid for PayoutEOTMths.