Redadublex
Redadublex

Reputation: 129

Bootstrap required attribute in asp.net mvc razor view

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" } })

Upvotes: 1

Views: 2208

Answers (1)

Ehsan Sajjad
Ehsan Sajjad

Reputation: 62498

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

@Html.TextBoxFor(m=>m.exclure.libelle,new{ @class = "form-control",required="required" })

Upvotes: 2

Related Questions