The following code disable it the first time but it would not enable it back. It seems the removeAttr does not work. Enable Disable Muilti-Select Listbox in jQuery.
Thanks
<script type="text/javascript">
$('#RecurrentPatternId').change(function () {
if ($(this).val() == '1')
{
$("#ScheduleDaysIds").removeAttr('disabled');
$("#MonthDay").val("");
$("#MonthDay").attr('disabled', 'disabled');
}
else
{
$("#ScheduleDaysIds").val("");
$("#ScheduleDaysIds").attr('disabled', 'disabled');
$("#MonthDay").removeAttr('disabled');
}
});
$(function () {
$("#RecurrentPatternId").change();
$('#ScheduleDaysIds').multiselect({
disabledText: 'Disabled ...'
});
});
</script>
div class="form-group">
<label asp-for="RecurrentPatternId" class="control-label col-md-2"></label>
<div class="col-md-10 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon alert-info"><i class="glyphicon glyphicon-time alert-info"></i></span>
<select asp-for="RecurrentPatternId" class="form-control" asp-items="ViewBag.RecurrentPatternId" ></select>
</div>
<span asp-validation-for="RecurrentPatternId" class="text-danger"></span>
</div>
</div>
<div class="form-group">
<label asp-for="MonthDay" class="col-md-2 control-label"></label>
<div class="col-md-10 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon alert-info"><i class="glyphicon glyphicon-calendar alert-info"></i></span>
<input asp-for="MonthDay" class="form-control" />
</div>
<span asp-validation-for="MonthDay" class="text-danger"></span>
</div>
</div>
<div class="form-group">
<label asp-for="Weekdays" class="control-label col-md-2"></label>
<div class="col-md-10 inputGroupContainer">
<div class="input-group" name="weekdays">
<span class="input-group-addon alert-info"><i class="glyphicon glyphicon-calendar alert-info"></i></span>
Listbox
</div>
</div>
</div>