2

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","ReplaceValidationMessageContents":true,"ValidationMessageId":"Title_validationMessage","ValidationRules":[{"ErrorMessage":"Title must be between 60 and 10 characters","ValidationParameters":{"minimumLength":0,"maximumLength":60},"ValidationType":"stringLength"}]};//]]>

1 Answer 1

4

It appears to be a bug in MVC 2 that was fixed in MVC 3

Sign up to request clarification or add additional context in comments.

4 Comments

Can you give a reference for this, please?
I checked the source code differences between 2 and 3 after finding it working in MVC 3
isn't asp.net MVC a closed source ?
@JGilmartin you can view the source for mvc at aspnetwebstack.codeplex.com it also includes source for a lot of the webstack from microsoft.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.