I have the following textboxfor in my view
@Html.TextBoxFor(m => m.AdvertModel.Title, new
{
@class = "form-control",
type = "text",
placeholder = "Enter a descriptive title about the item for sale",
id = "Enter a descriptive title",
data_val_required = "The Title field is required.",
data_val = "true"
})
You can see I have added the data_val_required and data_val attributes to do it, this renders as follows:
<input id="Enter a descriptive title" class="form-control" type="text" value="" placeholder="Enter a descriptive title about the item for sale" name="Title" data-val-required="The Title field is required." data-val-maxlength-max="100" data-val-maxlength="The field Title must be a string or array type with a maximum length of '100'." data-val="true">
When I run the application and this and leave it empty and click submit the ModelState.isValid is always true, when I would expect it to be false, why does it keep saying it true?