ASP.NET client side validation with dataannotations - javascript minimumlength zero

Posted by Kordonme on Stack Overflow See other posts from Stack Overflow or by Kordonme
Published on 2010-04-27T11:53:37Z Indexed on 2010/04/27 17:23 UTC
Read the original article Hit count: 223

Hi!

I'm doing client side validation on a project I'm working on. Everything works, except for the minimumlength property of the StringLength attribute (it works when submitting and a serverside validation is done):

[StringLength(50, MinimumLength = 6)]

The javascript generated by Html.EnableClientValication(); is the following:

// snip 
{"FieldName":"User.Password","ReplaceValidationMessageContents":true,"ValidationMessageId":"User_Password_validationMessage","ValidationRules":[{"ErrorMessage":"The field Password must be a string with a minimum length of 6 and a maximum length of 50.","ValidationParameters":{"minimumLength":0,"maximumLength":50},"ValidationType":"stringLength"}]}],"FormId":"form0","ReplaceValidationSummary":false})

The important thing is here:

{"minimumLength":0,"maximumLength":50}

It produces javascript with the wrong minimumproperty. You guys have a hint? Is this a possible bug?

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about validation