Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not getting validation message for @Html.DropDownListFor() once Chosen jquery is used

Code is given below:
If i do not select any value in the combobox and press submit, no validation message is asked.

<tr>
            <td>Department </td>
            <td> : </td>
            <td class="@*@Model.NoEdit*@">    
                @Html.DropDownListFor(m => m.DepartmentId, new SelectList(Model.Departments, "SelectedDepartmentId", "DepartmentCode"), "-- Select Department--", new {@class = "chosen-select", id = "cboDeptartment" })
                @Html.ValidationMessageFor(model => model.DepartmentId)
            </td>
like image 715
Joseph Avatar asked Jan 06 '14 13:01

Joseph


1 Answers

Solved after a lot of research...

$(document).ready(function () {
    var validator = $("#Your_form_id").data('validator');
    validator.settings.ignore = ":hidden:not(select)";
});

like image 55
Joseph Avatar answered Sep 22 '22 15:09

Joseph