combox I'm using unobtrusive validation in an MVC3 app. I've got a dropdown list with a [Required] validator on it. This is my Model (simplified):
[Required(ErrorMessage = "Please select From Employee.")]
public string CurrentEmpId { get; set; }
public List<SelectListItem> CurrentEmp { get; set; }
And this is my View (simplified):
@Html.LabelFor(m => m.CurrentAdvisers)
@Html.DropDownListFor(m => m.CurrentEmpId, new SelectList(Model.CurrentEmp, "Value", "Text", Model.CurrentEmpId), "Please Select")
@Html.ValidationMessageFor(m => m.CurrentEmpId)
Now this is all working bo diddly until I make the dropdown list into a JQuery UI combox jqueryui.com/demos/autocomplete/#combobox (see last argument).
@Html.DropDownListFor(m => m.CurrentEmpId, new SelectList(Model.CurrentEmp, "Value", "Text", Model.CurrentEmpId), "Please Select", new { @class = "selAutoComplete" })
The validation fires OK when I press a submit button and nothing has been selected. There is one annoying thing that doesn't work though. When an error is fired, if I then go and correct the error by selecting something in the dropdown and tab out the error doesn't disappear. This did happen when it was a normal select box.
It's probably to do with the fact that the <select>
is now hidden and replaced by an <input>
by JQuery, but I can't figure out how to fire the correct js to remove the error message.
Any help will be gratefully received!
Thanks in advance