Reputation: 1066
in my MVC3 application, I've a form with 2 dropdownlists that aren't required. So, I haven't added any annotation to the related attributes on the partial class. Viewing the html code generated when I add a new object, no client validation code is added and all goes fine. The problem rises when I try to modify an object that has values on attributes related with the dropdownlists because automatically is added this code
data-val="true" data-val-number="The field IDCategory must be a number." data-val-required="The IDCategory field is required." id="ddlCategory" name="List.Category.IDCategory"
So, if on this object I try to set no value on the dropdownlists and after submit the form, it is fired the validation error. I think that the solution are 2:
Thanks in advance!
Upvotes: 2
Views: 1267
Reputation: 2589
You can always use JQuery to remove client-side validation class from a particular control.
$('#myControl').removeClass('myClass');
Upvotes: 1