Remove or rename that form-control div to some other name.The same id name for input tag and div is conflicting and the code is looking for the first one .Thats why here no codes working.I edited accordingly.Kindly go through it.include jquery .Its important.
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js" ></script>
<script>
$(function () {
$("input[name='Ongoing']").click(function () {
if ($("#ongoing").is(":checked")) {
$("#deadline").removeAttr("disabled");
} else {
$("#deadline").attr("disabled", "disabled");
}
});
});
</script>
</head>
i edited your code as required.
<body>
<form>
<div class="form-group" id="deadlinediv" >
<input type="text" class="datepicker form-control" id="deadline" name="deadline" placeholder="DD/MM/YYYY" disabled="disabled">
<input type="checkbox" value="ongoing" name="Ongoing" id="ongoing" >
<label for="ongoing">Ongoing</label>
</div>
</form>
</body>
</html>
So many other ways already explained .May be this too will help somebody.
deadlinefor div asidwhich caused the issue