How to get unobtrusive validation on my JQueryUI e

2019-09-06 05:39发布

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?

2条回答
戒情不戒烟
2楼-- · 2019-09-06 06:38

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 = "";
查看更多
Deceive 欺骗
3楼-- · 2019-09-06 06:39

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();
});
查看更多
登录 后发表回答