1

I need to use the required attribute, so the field shoud not be empty

   <input type="text" class="form-control" id="inputName" required>

in the razor view, more specifically in this example

  @Html.EditorFor(model => model.exclure.libelle, new { htmlAttributes = new { @class = "form-control" } })
1
  • You could make libelle required in the model? Commented Mar 16, 2015 at 10:31

1 Answer 1

2

You can specify in htmlAttributes with TextBoxFor() this way:

@Html.TextBoxFor(m=>m.exclure.libelle,new{ @class = "form-control",required="required" })
Sign up to request clarification or add additional context in comments.

Comments

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.