因此,我一直在寻找有关此处的问题,并且已经走得足够远,可以textbox
通过更改 的选择来禁用 a ,但是如果返回到其默认值 ,dropdownlist
我希望能够再次启用它。 dropdownlist
<Select an Access Point>
查询:
$('#selectAccessPoint').change(function () {
if ($('#selectAccessPoint :selected').val != "2147483647")
$('#newAccessPoint').attr('disabled', 'disabled');
else {
$('#newAccessPoint').removeAttr('disabled');
$('#newAccessPoint').attr('enabled', 'enabled');
}
});
textbox
和的HTML dropdownlist
:`
<tr>
<td><label for ="AccessPoint" class="xl">Access Point:</label></td>
<td><%= Html.DropDownListFor(x => x.AccessPointsList.Id, Model.AccessPointsList.AccessPoints.OrderByDescending(x => x.Value.AsDecimal()), new { @id = "selectAccessPoint", @class = "info1"})%></td>
</tr>
<tr>
<td><label for ="AccessPoint" class="xl">Or Add New:</label></td>
<td><%= Html.TextBoxFor(x => x.AccessPointsList.AccessPoint, new { @id = "newAccessPoint", @class = "location info2 xl", maxlength = "250" }) %></td>
</tr>
生成的 HTML:(
<select class="info1" data-val="true" data-val-number="The field Id must be a number." data-val-required="The Id field is required." id="selectAccessPoint" name="AccessPointsList.Id"><option value="2147483647"><Select an Access Point></option>
那里有更多选项,但这是我要比较的选项)
<input class="location info2 xl" id="newAccessPoint" maxlength="250" name="AccessPointsList.AccessPoint" type="text" value="">
注意:attr
必须用作prop
给我一个错误,val()
也给我一个错误。