0

I use the below url code for date validation in mvc, but it is not showing the error.

"MVC Model Range Validator?"

any help?

Community
  • 1
  • 1
tester
  • 57
  • 1
  • 1
  • 6

1 Answers1

0

Your comment in that question says (ErrorMessage="") which will give a blank error message and ergo you will not see a message. delete this statement to use the default or write your own.

Steven Wood
  • 2,675
  • 3
  • 26
  • 51
  • sorry it is my mistake, i use the error message , but it is not showing. – tester Oct 08 '13 at 11:23
  • could you post the actual code you are using, I know you say you are using the same code but you may have made an error whilst altering it for your needs. without this I cant really say whats wrong. – Steven Wood Oct 08 '13 at 11:25
  • In model i use below code [Required(ErrorMessage="Date field is requireddd")] [DataType(DataType.Date)] [DateRange(ErrorMessage = "Must be between 18 and 65 years ago")] public DateTime DOB { get; set; } – tester Oct 08 '13 at 11:28
  • if this is a custom attribute, did you remember to set the error message in the constructor of the custom attribute? it may be recieving the error message but not setting the error message property in the base class – Steven Wood Oct 08 '13 at 12:14