Range validation not working properly in MVC3

Posted by Colin Desmond on Stack Overflow See other posts from Stack Overflow or by Colin Desmond
Published on 2011-02-28T15:18:55Z Indexed on 2011/02/28 15:24 UTC
Read the original article Hit count: 268

I am generating data validation javascript in an Asp.Net MVC 3 application with the following code

[DisplayName("Latitude Degrees")]
[Range(0, 90, ErrorMessage = "Latitude degrees must be between {1} and {2}")]
public Int32? LatitudeDegrees { get; set; }

on a view model. When it was MVC2 this worked just fine, if I entered a value outside of 0-90 in the textbox I got the validation warnings.

Since I moved the application to MVC 3, whenever I put any value into the texbox, legal or illegal I get the validation error appear next to it.

I have EnableClientValidation set to true and UseUnobtrusiveJavascript is off (nothing in web.config or the views to turn it on).

© Stack Overflow or respective owner

Related posts about asp.net-mvc-3

Related posts about dataannotations