I have a #Email text box and I have two menus with the lists down, which are #Carriers and #Phones. When email is entered, I want to include only the Carriers field, but not the Phones field. When media is selected, the Phones drop-down list should be enabled. The Phones drop-down list can only be enabled if email and media are selected. If the user enters an email address and selects an item from # media and # phones, and then the email is deleted, two drag and drop menus must be disabled. The way I want it to work is when the user selects items from # media and # phones, and then removes the email address, and the drop-down menus should be disabled and set by default. Now it’s disconnecting,but does not return them by default.
<script>
$(document).ready(function () {
$('#Email').on('input change', function () {
if ($(this).val() == '') {
$('#Carriers').prop('disabled', true);
$('#Phones').prop('disabled', true);
}
else {
$('#Carriers').prop('disabled', false);
}
});
});
<script>
$(document).ready(function () {
$('#Carriers').change(function () {
if ($('#Carriers').val() == '') {
$('#Phones').prop('disabled', true);
}
else {
$('#Phones').prop('disabled', false);
}
});
});
<!--this row carrier and phones-->
<div class="form-group">
<div class="col-lg-1 col-lg-offset-1 col-md-1 col-sm-1">
@Html.LabelFor(model => model.Carriers)
</div>
<div class="col-lg-2 col-md-2 col-sm-2">
@Html.DropDownListFor(model => model.Carriers, new SelectList(ViewBag.Carriers, "ID", "Carrier1"), "Select a Carrier", new
{
@disabled = "disabled",
data_bind = "value: Request.Carriers",
@class = "form-control",
data_width = "95%",
data_toggle = "tooltip",
data_placement = "top",
title = "Requested Plan Carrier"
})
@Html.ValidationMessageFor(model => model.Carriers, "", new { @class = "text-danger" })
</div>
<div class="col-lg-1">
@Html.LabelFor(model => model.Phones)
</div>
<div class="col-lg-3 col-md-3 col-sm-3">
@Html.DropDownListFor(model => model.Phones, new SelectList(ViewBag.Phones as System.Collections.IEnumerable, "PhoneID", "Name"), "Select a Phone", new
{
@disabled = "disabled",
data_bind = "value: Request.Phones",
@class = "form-control",
data_width = "95%",
data_toggle = "tooltip",
data_placement = "top",
title = "Requested Equipment"
})
@Html.ValidationMessageFor(model => model.Phones, "", new { @class = "text-danger" })
</div>