<div class="editor-field">
@Html.TextBox("manager-control", "", new { id = "manager-control", @class = "form-control", placeholder = "Type to search..." })
@Html.HiddenFor(model => model.manager, new { id = "manager-dn" })
@Html.ValidationMessageFor(model => model.manager)
</div>
manager-control is an autocomplete, autocomplete select handler adds a value to the hidden field which represents the value for the manager. I can enable the validation message for the hidden field, that's fine, but the validation message itself is displayed outside the form.
I'd like to display the message itself on the manager-control element. What would be the best way to do that? The manager-dn field MUST have a value when the form is submitted, so simply saying that the manager-control should be filled out will not work.
The two ways I can think of are to use LabelFor instead of HiddenFor, and thus display an ugly text string, or find a way to display the validation message above the input.
EDIT:
This is useful in situations where you don't want to display the value of the selected AutoComplete item to the user but do want to validate that something has been selected.