How to make an input field required in MVC

Home > Search > How-to
  by

Add required = "required" to the HTML attributes.

@Html.EditorFor(model => model.article_title, new { htmlAttributes = new { @class = "form-control", required = "required" } })

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter in the box below so that we can be sure you are a human.




Comments