希望能够使用MVC验证+我的自定义JavaScript验证。
MVC的验证是非常好的模型验证。这里的主要问题是我有更复杂的验证。我自己的JavaScript验证+ MicrosoftMvcValidation。可能吗 ?我将如何
例:案例与MVC验证
<div class="editorSmall">
<div class="editor-label bold">
<%: Html.LabelFor(model => model.Location.CurID)%>:
</div>
<div class="editor-field">
<%:Html.DropDownListFor(model => model.Location.CurID, Model.CurrenciesList)%>
<%: Html.ValidationMessageFor(model => model.Location.CurID)%>
</div>
</div>
<div class="editorSmall">
<div class="editor-label bold">
<%: Html.LabelFor(model => model.Location.UnitID)%>:
</div>
<div class="editor-field">
<%:Html.DropDownListFor(model => model.Location.UnitID,Model.UnitList)%>
<%: Html.ValidationMessageFor(model => model.Location.UnitID)%>
</div>
</div>
正如你可以看到我使用ValidationMessageFor模型验证。
EX:自定义验证。
在这里,我想在列表框进行验证。我希望它是必需的。因为这不是强类型的,所以我需要其他方法来进行验证。
<div class="editorSmall" >
<div class="editor-label bold">
<label><%:Model.GrpName1%>:</label>
</div>
<div class="editor-field">
<%: Html.ListBox("Model_Groupe1", new MultiSelectList(Model.Groupe1, "GrpDescID", "GrpDescTxt", Model.Groupe1Selected.Select(g => g.GrpDescID)), new { @class = "grplb" })%>
</div>
</div>
我想要什么: 如果我点击提交按钮,我想建在MVC验证+在同一时间我自定义的验证......我的意思是,如果第一次验证(MVC之一)无效,我希望我的自定义验证也可以执行验证。
感谢