KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a curious problem with ASP.NET MVC3 client-side validation. I have the following class: public class Instrument : BaseObject { public int Id { get; set; } [Required(ErrorMessage = "Name is required.")] [MaxLength(40, ErrorMessage = "Name cannot be longer than 40 characters.")] public string Name { get; set; } } From my view: <div class="editor-field"> @Html.EditorFor(model => model.Name) @Html.ValidationMessageFor(model => model.Name) </div> And here's the generated HTML I get for the textbox for this field: <input class="text-box single-line" data-val="true" data-val-required="Name is required." id="Name" name="Name" type="text" value=""> No sign of the MaxLengthAttribute , but everything else seems to be working. Any ideas what's going wrong?
Tags (comma-separated)
Save Edits
Cancel