我有一个简单的向导,由三个简单的步骤组成。
在前两个步骤中,我有一些带有几个选择控件的表单控件,这些控件由所选插件处理
<div class="col-lg-6 col-lg-offset-1">
<label for="ExpirationMode" class="control-label">Da operazione</label>
<div class="">
<select name="ExpirationMode" id="ExpirationMode"
class="chosen-select form-control" data-placeholder="Select an item" data-rule-required="true" data-msg-required="Required field">
<option value=""></option>
@foreach ( ExpirationModeViewModel e in expirationModeList ) {
<option value="@e.ExpirationModeID">@e.Description</option>
}
</select>
</div>
</div>
使用以下 javascript
$('.chosen-select').chosen({
disable_search_threshold: 10,
no_results_text: 'Oops, no results found',
allow_single_deselect: true,
width: '100%'
});
为了使用所选插件处理验证,我在onStepChanging
事件中添加了以下验证器设置
onStepChanging: function (event, currentIndex, newIndex) {
// Disable validation on fields that are disabled or hidden.
form.validate().settings.ignore = ":disabled,:hidden:not('select.form-control')";
// Start validation; Prevent going forward if false
return form.valid();
},
当我在第二个面板中添加另一个选定的选择时,就会出现问题。该指令form.validate().settings.ignore = ":disabled,:hidden:not('select.form-control')";
还试图验证第二个面板中的选定元素。
我该如何解决这个问题?我可以告诉验证器只验证当前面板中包含的控件吗?