I have a simple wizard made of three simple steps.
In the first two steps I have some form controls with a couple of select control which are handled by the chosen plugin
<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>
with the following javascript
$('.chosen-select').chosen({
disable_search_threshold: 10,
no_results_text: 'Oops, no results found',
allow_single_deselect: true,
width: '100%'
});
To handle the validation with the chosen plugin I have added the following validator settings in the onStepChanging
event
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();
},
The problem happens when I add another chosen select in the second panel. The instruction form.validate().settings.ignore = ":disabled,:hidden:not('select.form-control')";
is trying to validate also the chosen elements that are in the second panel.
How can I solve this? Can I tell the validator to validate only the controls contained in the current panel?