srkirkland / DataAnnotationsExtensions

Validation extensions for DataAnnotations, including optional MVC client validation implementations
https://dataannotationsextensions.apphb.com/
BSD 3-Clause "New" or "Revised" License
308 stars 86 forks source link

Min attribute incorrectly fires when the minimum is a single digit #60

Closed tommytayman closed 8 years ago

tommytayman commented 10 years ago

I have an integer property with the Min attribute set to 5. When using jQuery.unobtrusive validation plugin, jQuery will mark any value not starting with a 5 or greater as invalid and show the corresponding error message. Meaning the values 5 through 9 as well as 50-99, 500-999 etc all will pass validation. Any value not starting with a 5 or greater such as 10-49, 100-499, etc. will fail the javascript validation and display the error message. When the minimum is set to 10 or higher, the validation attributes all work as expected.

I confirmed this on a clean MVC 5 project using the following versions:

The work around is to use the Range() attribute within the .NET framework. Additional information located here - http://stackoverflow.com/questions/23687162/mvc-unobtrusive-validation-incorrectly-firing

Vyeche commented 10 years ago

I'm having a similar issue with Max Attribute.

srkirkland commented 8 years ago

seems to be specific to mvc 5 since the version currently using using the old MVC3 stuff is working. I'm going to build out an MVC5 version here soon so i'll keep this around to make sure to fix it.