How to validate input that was hidden in ASP.NET MVC 4

1.1k views Asked by At

I have a editable dropdownlist like this one.

http://jqueryui.com/autocomplete/#combobox

It's hide a select and made a autocomplete textbox like this.

<select class="autocombobox" data-val="true" data-val-required="This field is required."
 id="F_FFormat" name="F.FFormat" style="display: none;">
<option value="">....</option>
......
</select>

When i remove style "display: none" it will validate correctly on client side. But if it still hidden then it will not be validated at all.

I do some googling and try this script

$.validator.setDefaults({ ignore: null });

but it not work either.

How can i fix this problem?

Thank you in advance.

1

There are 1 answers

0
Vivekh On BEST ANSWER

Try this:

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