ASP .NET MVC Disable Client Side Validation at Per-Field Level

后端 未结 7 2040
梦毁少年i
梦毁少年i 2020-11-27 02:50

I\'m using ASP .NET MVC 3 with Data Annotations and the jQuery validate plugin.

Is there a way to mark that a certain field (or certain data annotation) should only

相关标签:
7条回答
  • 2020-11-27 03:51

    I ran into trouble with data_val="true". I had a sequence of radio buttons tied to a single property in my model. The data validation only worked when I applied data_val="true" to the first @Html.RadioButtonFor call.

    In debugging this, I discovered you can also disable or alter individual rules on the client side by using data_rule_??. The rules can be found in the jquery validation documentation.

    for example;

    @Html.RadioButtonFor(m => m.Answer, "Yes", new { data_rule_Required = "false" });
    @Html.TextBoxFor(m => m.Answer, new { data_rule_minlength = "10" }
    
    0 讨论(0)
提交回复
热议问题