ASP.NET MVC - Custom validation message for value types

Posted by Giovanni Galbo on Stack Overflow See other posts from Stack Overflow or by Giovanni Galbo
Published on 2009-03-14T17:07:56Z Indexed on 2010/04/23 13:33 UTC
Read the original article Hit count: 450

When I use UpdateModel or TryUpdateModel, the MVC framework is smart enough to know if you are trying to pass in a null into a value type (e.g. the user forgets to fill out the required Birth Day field) .

Unfortunately, I don't know how to override the default message, "A value is required." in the summary into something more meaningful ("Please enter in your Birth Day").

There has to be a way of doing this (without writing too much work-around code), but I can't find it. Any help?

EDIT

Also, I guess this would also be an issue for invalid conversions, e.g. BirthDay = "Hello".

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about validation