Как я могу изменить атрибут моего текстового поля на чтение, а не скрывать его?
Раскрывающийся список:
<div class="form-group">
@Html.LabelFor(model => model.CIVSTAT, "Civil Status", htmlAttributes: new { @class = "control-label" })
<select class="form-control" id="CIVSTAT" name="CIVSTAT">
<option> </option>
<option>Single</option>
<option>Married</option>
<option>Widowed</option>
<option>Separated</option>
<option>Divorced</option>
</select>
@Html.ValidationMessageFor(model => model.CIVSTAT, "", new { @class = "text-danger" })
</div>
Текстовое поле:
<div class="form-group">
@Html.LabelFor(model => model.SPOUSE, "Spouse", htmlAttributes: new { @class = "control-label" })
@Html.EditorFor(model => model.SPOUSE, new { htmlAttributes = new { @class = "form-control", @autocomplete = "off", placeholder = "Spouse's Name", maxlength = 40, @id="spouse" } })
@Html.ValidationMessageFor (model => model.SPOUSE, "", new { @class = "text-danger" })
</div>
JS Код:
< script >
$("#CIVSTAT").change(function () {
if ($(this).val() == "Single") {
$('#spouse').hide();
}else {
$('#spouse').show();
}
});