AutoCompleteFor field required

-1

I have the following code:

@Html.LabelFor(model => model.IdPuertoOrigen, "Puerto de Origen")
@Html.AutocompleteFor(model => model.IdPuertoOrigen, model => model.PuertoOrigen_Descripcion, false, Url.Action("AutocompletePuertoSearch", "Puerto", new { area = "Maestros" }), "width: 80%;")
@Html.ValidationMessageFor(model => model.IdPuertoOrigen)

The autocompletefor I need it to be mandatory to fill out, but I do not know how to do it, they recommended me with javascript but I can not find the form, if you can help me, I would really appreciate it.

    
asked by Gustavo Rincon 30.04.2018 в 19:31
source

1 answer

0

You could set attributes html: example

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

use the required I hope I help you!

    
answered by 30.04.2018 / 19:54
source