I am trying to disable/enable an @Html.TextBoxFor
in razor using an @Html.CheckBoxFor
I have defined my CheckBoxFor in this manner:
@Html.CheckBoxFor(m => m.ResYearChecked, new { Name = "ResYearChecked", id = "ResYearChecked" })
@Html.TextBoxFor(m => m.SearchResYear, new { Name = "SearchResYear", id = "SearchResYear" })
and I am trying to call the script:
<script>
$('ResYearChecked').change(function () {
$("SearchResYear").prop("disabled", !$(this).is(':checked'));
});
</script>
Do I need to add the onclick
attribute to the CheckBoxFor
?
Aucun commentaire:
Enregistrer un commentaire