ASP.NET MVC 2 Data Annotation Validation -- StringLength Minimum not working on client-side
On one of my models I have a property annotated with:
[StringLength(60, ErrorMessage="Title must be between 60 and 10 characters", MinimumLength=10)]
When the form posts to the server, if it's under 10 characters, then validation fails as it should do. However, on the client-side, it only checks that it's under 60 characters -- not also above 10 characters.
Here's the JSON, note that the minimum length is 0:
<![CDATA[if (!window.mvcClientValidationMetadata) { window.mvcClientValidationMetadata = []; }window.mvcClientValidationMetadata.push({"Fields":[{"FieldName":"Title","ReplaceValidatio开发者_开发问答nMessageContents":true,"ValidationMessageId":"Title_validationMessage","ValidationRules":[{"ErrorMessage":"Title must be between 60 and 10 characters","ValidationParameters":{"minimumLength":0,"maximumLength":60},"ValidationType":"stringLength"}]};//]]>
It appears to be a bug in MVC 2 that was fixed in MVC 3
精彩评论