How to get unobtrusive validation on my JQueryUI element, (Combobox)?

痴心易碎 提交于 2019-12-13 06:30:30

问题


In ASP NET MVC, I had an @Html.DropDownList in which the validation for the field was working just fine.

As I needed the field to be editable I decided to use the JQueryUI Combobox, but right now I'm not getting the unobtrusive validation until I submit the form. So when I pick a right value, the error message posted before doesn't go away.

How can I make the unobtrusive validation work again on each Key Press on my JQueryUI Combobox?


回答1:


The fields wasn't getting the validation, because the got hidden when you use the JQueryUi Combobox. Whith the next script in the Document.Ready event you specify the validator to not ignore the hidden fields.

    var validator = $("Form").data('validator');
    validator.settings.ignore = "";



回答2:


It would be worth checking the render html to ensure the correct unobtrusive validation attributes have been added

otherwise have you tried calling the validate function on the change event for the combo box.. put something like this in the $(document).ready portion

$('#combobox').change(function(){
       $(this).validate();
});


来源:https://stackoverflow.com/questions/13516841/how-to-get-unobtrusive-validation-on-my-jqueryui-element-combobox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!