0

I have Input checkbox element inside td tag of a table. When I try to set readonly attribute to checkbox , not working , still it can be ticked or unticked even if I set readonly attribute to input checkbox.

var isdisabled = true
var isDofDisabled = true

<td>
  <div>
    <span>
      <input type="checkbox" 
        readonly="@(isdisabled || isDofDisabled ? " readonly" : null)" 
        asp-for="@Model.[i].IsDayOffMarked" />
    </span>
    <input type="number" 
      readonly="@(isdisabled || isDofDisabled ? "readonly" : null)" 
      placeholder="0.00" 
      style="text-align:center;vertical-align:central" 
      class="form-control format-text" 
      asp-for="@Model.[i].DayOffHrs" />
  </div>
</td>
naveen
  • 51,042
  • 46
  • 158
  • 241
Alan Pauil
  • 159
  • 1
  • 9
  • Do you tried? disabled="@(isdisabled || isDofDisabled ? "disabled" : null)" – cura May 17 '21 at 13:49
  • @Alan Pauil: See [Razor how to create a CheckBox and make it READONLY?](https://stackoverflow.com/q/11308661/6630084) – Victor May 17 '21 at 13:51

1 Answers1

0

Input Checkbox cannot be set as readonly. You should set it as disabled instead since checkbox doesn't support readonly.